Change elements of an array based on conditional and input values.
Similar to np.putmask(a, mask, vals), the difference is that place uses the first N elements of vals, where N is the number of True values in mask, while putmask uses the elements where mask is True.
Note that extract does the exact opposite of place.
Parameters: | a : array_like
mask : array_like
vals : 1-D sequence
|
---|
Examples
>>> x = np.arange(6).reshape(2, 3)
>>> np.place(x, x>2, [44, 55])
>>> x
array([[ 0, 1, 2],
[44, 55, 44]])