I have a numpy array 'A' of size 571x24 and I am trying to find the index of zeros in it so I do:
import numpy as np
z1 = np.where(A==0)
You can just check this with the equality operator in python with numpy. Example:
>>> A = np.array([[0,2,2,1],[2,0,0,3]]) >>> A == 0 array([[ True, False, False, False], [False, True, True, False]], dtype=bool)
np.where() does something else, see documentation. Although, it is possible to achieve this with
np.where() using broadcasting. See documentation.
>>> np.where(A == 0, True, False) array([[ True, False, False, False], [False, True, True, False]], dtype=bool)