NumPy has the efficient function/method nonzero() to identify the indices of non-zero elements in an ndarray object. What is the most efficient way to obtain th
ndarray
You can search for any scalar condition with:
>>> a = np.asarray([0,1,2,3,4]) >>> a == 0 # or whatver array([ True, False, False, False, False], dtype=bool)
Which will give back the array as an boolean mask of the condition.