I have the foll. numpy array:
arr = [0,0,0,1,0,0,0,0,0,0,0,1,0,1,0,1,0,0,0,0,0,0,0,0,0,0,1]
This is how I am getting the indices of all 0's in the array:
inds = []
for index,item in enumerate(arr):
if item == 0:
inds.append(index)
Is there a numpy function to do the same?
numpy.argwhere
what you're after? Something likenumpy.argwhere(arr == 0)