Replaces specified elements of an array with given values.
The indexing works on the flattened target array. put is roughly equivalent to:
a.flat[ind] = v
Parameters: | a : ndarray
ind : array_like
v : array_like
mode : {‘raise’, ‘wrap’, ‘clip’}, optional
|
---|
Examples
>>> a = np.arange(5)
>>> np.put(a, [0, 2], [-44, -55])
>>> a
array([-44, 1, -55, 3, 4])
>>> a = np.arange(5)
>>> np.put(a, 22, -5, mode='clip')
>>> a
array([ 0, 1, 2, 3, -5])