count#

count(arr=None, val=None, eps=1e-06, **kwargs)[source]#

Count the number of matching elements.

Similar to numpy.count_nonzero(), but allows for slight mismatches (e.g., floats vs. ints). Equivalent to len(sc.findinds()).

Parameters:

Examples:

sc.count(rand(10)<0.5) # returns e.g. 4
sc.count([2,3,6,3], 3) # returns 2

New in version 2.0.0.