[Numpy-discussion] counting non-zero entries in an ndarray

Alan G Isaac alan.isaac@gmail....
Wed Dec 22 08:20:02 CST 2010

On 12/22/2010 9:16 AM, Ian Stokes-Rees wrote:
> a != 0
> will be used, but I'm not sure then how to "count" the number of "True"
> entries.

(a != 0).sum()

Alan Isaac

More information about the NumPy-Discussion mailing list