Take a look numpy.uniqueand numpy.bincount.
eg.
import numpy as np
x = (np.random.random(100) * 5).astype(np.int)
unique_vals, indicies = np.unique(x, return_inverse=True)
counts = np.bincount(indicies)
print unique_vals, counts
Edit: Sorry, I misunderstood your question ...
One way to get unique strings is to view objects as a structured array ...
In your case, you have a 2D bools array. So maybe something like this?
import numpy as np
numrows, numcols = 10,3
x = np.random.random((numrows, numcols)) > 0.5
x = x.view(','.join(numcols * ['i1']))
unique_vals, indicies = np.unique(x, return_inverse=True)
counts = np.bincount(indicies)
print unique_vals, counts
, , ... ( , ):
def unique_rows(data):
unique = dict()
for row in data:
row = tuple(row)
if row in unique:
unique[row] += 1
else:
unique[row] = 1
return unique
defaultdict:
from collections import defaultdict
def unique_rows(data):
unique = defaultdict(int)
for row in data:
unique[tuple(row)] += 1
return unique
, , "numpy-thonic" ... ( ! , , , , ).