numpy.argwhere() function is used to find the indices of array elements that are non-zero, grouped by element.
Syntax : numpy.argwhere(arr)
arr : [array_like] Input array.
Return : [ndarray] Indices of elements that are non-zero. Indices are grouped by element.
Code #1 :
Input array : [[2, 0, 7], [0, 5, 9]] Output indices of non zero array element: [[0 0] [0 2] [1 1] [1 2]]
Code #2 :
Input array : [[0 1] [2 3] [4 5] [6 7]] Output indices greater than 4: [[2 1] [3 0] [3 1]]
- Python | Merge Python key values to list
- Reading Python File-Like Objects from C | Python
- Important differences between Python 2.x and Python 3.x with examples
- Python | Convert list to Python array
- Python | Index of Non-Zero elements in Python list
- Python | Sort Python Dictionaries by Key or Value
- Python | Add Logging to a Python Script
- Python | Add Logging to Python Libraries
- Python | Set 4 (Dictionary, Keywords in Python)
- Python | Visualizing O(n) using Python
- zip() in Python
- Any & All in Python
- bin() in Python
- Python vs PHP
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.