I have a scipy array, e.g.
a = array([[0, 0, 1], [1, 1, 1], [1, 1, 1], [1, 0, 1]])
I want to count the number of occurrences of each unique ele
for python 2.6 <
import itertools data_array = [[0, 0, 1], [1, 1, 1], [1, 1, 1], [1, 0, 1]] dict_ = {} for list_, count in itertools.groupby(data_array): dict_.update({tuple(list_), len(list(count))})