Sometimes we need to find out the indices of all null elements in the array. Numpy provides many functions to compute indices of all null elements.
Method 1: Finding indices of null elements using numpy.where()
This function returns the indices of elements in an input array where the given condition is satisfied.
numpy.where(condition[, x, y]) When True, yield x, otherwise yield y
Method 2: Finding indices of null elements using numpy.argwhere()
This function is used to find the indices of array elements that are non-zero, grouped by element.
Method 3: Finding the indices of null elements using numpy.nonzero()
This function is used to Compute the indices of the elements that are non-zero. It returns a tuple of arrays, one for each dimension of arr, containing the indices of the non-zero elements in that dimension.
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course