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

Alan G Isaac alan.isaac at gmail.com
Wed Dec 22 09:20:02 EST 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()

hth,
Alan Isaac




More information about the NumPy-Discussion mailing list