原文:https://docs.scipy.org/doc/numpy/reference/generated/numpy.place.html
校对:(虚位以待)
numpy.
place
(arr, mask, vals)[source]基于条件和输入值更改数组的元素。
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.
参数: | arr:ndarray
掩码:array_like
vals:1-D序列
|
---|
例子
>>> arr = np.arange(6).reshape(2, 3)
>>> np.place(arr, arr>2, [44, 55])
>>> arr
array([[ 0, 1, 2],
[44, 55, 44]])