numpy.char.replace()



This function returns a new copy of the input string in which all occurrences of the sequence of characters is replaced by another given sequence.

import numpy as np 
print np.char.replace ('He is a good boy', 'is', 'was')

Its output is as follows −

He was a good boy
numpy_string_functions.htm
Advertisements