bundles / numpy 2.5.0.dev0+git20251130.2de293a / numpy / argwhere
_ArrayFunctionDispatcher
numpy:argwhere
source: /dev/numpy/build-install/usr/lib/python3.14/site-packages/numpy/_core/numeric.py:624
Signature
def argwhere(a)Summary
Find the indices of array elements that are non-zero, grouped by element.
Parameters
a: array_likeInput data.
Returns
index_array: (N, a.ndim) ndarrayIndices of elements that are non-zero. Indices are grouped by element. This array will have shape
(N, a.ndim)whereNis the number of non-zero items.
Notes
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.
Examples
import numpy as np x = np.arange(6).reshape(2,3) x np.argwhere(x>1)✓
array([[0, 2],
[1, 0],
[1, 1],
[1, 2]])
See also
Aliases
numpy.argwhere