NumPy argwhere groups each selected element's coordinates into one row
Sometimes a coordinate table is easier to read than separate arrays of row and column indices. NumPy argwhere reports the positions of nonzero entries, with one coordinate row for each qualifying element. Academia Master Trader presents this English lesson for readers in Afghanistan, using constructed arrays to explain this layout and its distinction from direct array indexing.
Each output row describes one input position
After import numpy as np, define m = np.array([[0,6,0],[9,0,12]]). The call np.argwhere(m) returns [[0,1],[1,0],[1,2]]. Each row contains a row index followed by a column index because the input has two dimensions.
The first coordinate row locates six at row zero, column one. The second locates nine at row one, column zero. The third locates twelve at row one, column two. Coordinates count from zero and describe positions, not the numeric values stored at those positions.

Output shape combines the match count and input dimensions
The result has shape (3,2): three qualifying elements and two coordinates per element. More generally, its shape is (N,a.ndim), where N is the number of nonzero entries and a is the input array.
For v = np.array([0,-5,0,8]), the call np.argwhere(v) returns [[1],[3]], with shape (2,1). A vector needs only one coordinate per selected position, but the output still has a coordinate column. Negative five qualifies because it is nonzero; the function does not restrict selection to positive numbers.
The number of output rows and columns answers different questions. Rows count selected positions. Columns count the coordinates needed to locate one element in the original input. Neither dimension represents an average or a sum of the selected values.
For a three dimensional input, every coordinate row would contain three indices. The same reading rule applies: each index belongs to the corresponding input axis. Keep the input shape beside the coordinate table when explaining arrays with more than two dimensions.
Conditions can define the positions to report
The call np.argwhere(m > 8) returns [[1,0],[1,2]]. The comparison creates a Boolean condition array first. Argwhere then reports positions where that condition is True. Those coordinate rows identify nine and twelve in the original matrix.
For np.argwhere(m == 0), the result is [[0,0],[0,2],[1,1]]. This locates zeros by applying argwhere to the equality condition, rather than asking argwhere to treat zero as a nonzero input value. Distinguish the original matrix from the condition array that the function actually receives.
A coordinate table is not a direct indexing tuple
Do not assume that m[np.argwhere(m)] retrieves the listed nonzero values. Argwhere's output groups coordinates into rows and is not suitable as a direct array index for that purpose. Use m[np.nonzero(m)] or m[m != 0] to obtain [6,9,12].
If no entries qualify, the coordinate table has zero rows while retaining a column for each input dimension. For this two dimensional matrix, np.argwhere(m > 20) has shape (0,2).
Continue learning with Academia Master Trader at academiamastertrader.com.br and in Aprenda. Read each coordinate row as one location and choose a suitable indexing expression when values are needed.