xorbits.numpy.argwhere#

xorbits.numpy.argwhere(a)[源代码]#

Find the indices of array elements that are non-zero, grouped by element.

参数

a (array_like) – Input data.

返回

index_array – Indices of elements that are non-zero. Indices are grouped by element. This array will have shape (N, a.ndim) where N is the number of non-zero items.

返回类型

(N, a.ndim) ndarray

参见

where, nonzero

提示

np.argwhere(a) is almost the same as np.transpose(np.nonzero(a)), but produces a result of the correct shape for a 0D array.

The output of argwhere is not suitable for indexing arrays. For this purpose use nonzero(a) instead.

实际案例

>>> x = np.arange(6).reshape(2,3)  
>>> x  
array([[0, 1, 2],
       [3, 4, 5]])
>>> np.argwhere(x>1)  
array([[0, 2],
       [1, 0],
       [1, 1],
       [1, 2]])

This docstring was copied from numpy.