bundles / numpy 2.4.3 / numpy / ma / core / MaskedArray / put
function
numpy.ma.core:MaskedArray.put
source: /numpy/ma/core.py:4835
Signature
def put(self, indices, values, mode = raise)Summary
Set storage-indexed locations to corresponding values.
Extended Summary
Sets self._data.flat[n] = values[n] for each n in indices. If values is shorter than indices then it will repeat. If values has some masked values, the initial mask is updated in consequence, else the corresponding values are unmasked.
Parameters
indices: 1-D array_likeTarget indices, interpreted as integers.
values: array_likeValues to place in self._data copy at target indices.
mode: {'raise', 'wrap', 'clip'}, optionalSpecifies how out-of-bounds indices will behave. 'raise' : raise an error. 'wrap' : wrap around. 'clip' : clip to the range.
Notes
values can be a scalar or length 1 array.
Examples
import numpy as np x = np.ma.array([[1,2,3],[4,5,6],[7,8,9]], mask=[0] + [1,0]*4) x x.put([0,4,8],[10,20,30]) x
x.put(4,999) x
Aliases
numpy.ma.MaskedArray.put