-
numpy.argwhere(a)
[source] -
Find the indices of array elements that are non-zero, grouped by element.
Parameters: a : array_like
Input data.
Returns: index_array : ndarray
Indices of elements that are non-zero. Indices are grouped by element.
Notes
np.argwhere(a)
is the same asnp.transpose(np.nonzero(a))
.The output of
argwhere
is not suitable for indexing arrays. For this purpose usewhere(a)
instead.Examples
123456789>>> 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
]])
numpy.argwhere()

2025-01-10 15:47:30
Please login to continue.