[SciPy-user] counting pairs of values
Thu Jul 16 09:01:54 CDT 2009
I've got a series of observations that consist of pairs of
values (x, y) and I'm interested in counting the number of
occurrences of arbitrary pairs of values.
For example, if "a" is a 2-dimensional array such as
I want to find out how many (1, 2), or how many (3, 3) there
Currently I'm doing this:
numpy.logical_and(a[:,0] == 1, a[:,1] == 2).sum()
which seems to work well enough, but I wonder if there's a
more elegant/correct way of doing it.
More information about the SciPy-user