Most efficient (and pythonic) way to count False values in 2D numpy arrays?
Question: I am trying to count `False` value in an `np.array` like this:

    
    
    import numpy as np
    a = np.array([[True,True,True],[True,True,True],[True,False,False]])
    

I usually use this method:

    
    
    number_of_false=np.size(a)-np.sum(a)
    

Is there a better way?


Answer: Use
[`count_nonzero`](http://docs.scipy.org/doc/numpy-1.10.0/reference/generated/numpy.count_nonzero.html#numpy-
count-nonzero) to count non-zero (e.g. not `False`) values:

    
    
    >>> np.size(a) - np.count_nonzero(a)
    2
    

