On 9/7/06, Martin Spacek <[EMAIL PROTECTED]> 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])
>>> (a==3).sum()
2

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion

Reply via email to