numpy.argwhere(a)
-
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. -
此函数要实现的功能就是,返回 Array a 中所有大于1的值的索引
- argwhere: arg(argument的缩写),where(表示索引在哪里)。
>>> 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]])