[Numpy-discussion] ndarray.count() ?
alexander.belopolsky at gmail.com
Thu Sep 7 15:47:07 CDT 2006
On 9/7/06, Martin Spacek <scipy at mspacek.mm.st> wrote:
> What's the most straightforward way to count, say, the number of 1s or
> Trues in the array? Or the number of any integer?
> I was surprised to discover recently that there isn't a count() method
> as there is for Python lists. Sorry if this has been discussed already,
> but I'm wondering if there's a reason for its absence.
You don't really need count with ndarrays:
>>> from numpy import *
>>> a = array([1,2,3,1,2,3,1,2])
More information about the Numpy-discussion