VOOZH about

URL: https://www.geeksforgeeks.org/python/numpy-argwhere-in-python/

⇱ numpy.argwhere() in Python - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

numpy.argwhere() in Python

Last Updated : 24 Dec, 2018
numpy.argwhere() function is used to find the indices of array elements that are non-zero, grouped by element.
Syntax : numpy.argwhere(arr) Parameters : arr : [array_like] Input array. Return : [ndarray] Indices of elements that are non-zero. Indices are grouped by element.
Code #1 :
Output:
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 :
Output:
Input array : [[0 1]
 [2 3]
 [4 5]
 [6 7]]
Output indices greater than 4: 
 [[2 1]
 [3 0]
 [3 1]]
Comment