numpy.place(arr, mask, vals)
[source]
Change elements of an array based on conditional and input values.
Similar to np.copyto(arr, vals, where=mask)
, the difference is that place
uses the first N elements of vals
, where N is the number of True values in mask
, while copyto
uses the elements where mask
is True.
Note that extract
does the exact opposite of place
.
Parameters: |
|
---|
>>> arr = np.arange(6).reshape(2, 3) >>> np.place(arr, arr>2, [44, 55]) >>> arr array([[ 0, 1, 2], [44, 55, 44]])
© 2005–2019 NumPy Developers
Licensed under the 3-clause BSD License.
https://docs.scipy.org/doc/numpy-1.17.0/reference/generated/numpy.place.html