Given an array like this
a1= np.array([0,2,0,3])
if i want to return index of the first zero I do simply:
(a1==0).argmax(axis=0)
>> 0
however for the list like this:
a2= np.array([1,2,3,3])
It returns the same thing although the array does not have any zeros.
(a2==0).argmax(axis=0)
>> 0
How can I distinguish between these situations? Is it possible to impose that if an array does not have any zeros, the algorithm should return None?
.findas suggested in the linked duplicate not work? In fact, if you want a numpy solution,np.argwhere()exists. Why would you useargmax()?