How do you count the amount of zero rows of a numpy array?
array = np.asarray([[1,1],[0,0],[1,1],[0,0],[0,0]])
-> has three rows with all zero's, hence should give 3
Took me sometime to figure out this one and also couldn't find an answer on SO
You can use np.all if you're sure that the rows will have all zeros.
# number of rows which has non-zero elements
In [33]: sum(np.all(arr, axis=1))
Out[33]: 2
# invert the mask to get number of rows which has all zero as its elements
In [34]: sum(~np.all(arr, axis=1))
Out[34]: 3