unique_counts

mpsci.stats.unique_counts(x)

Unique values and their counts in the sequence x.

Returns two tuples, The first is the sorted sequence of unique values in x, and the second is a sequence of integers (same length as the first) that gives the number of occurrences of the corresponding value.

Examples

>>> from mpsci.stats import unique_counts
>>> x = [3, 4, 7, 8, 0, 0, 0, 7, 3, 2, 0, 0, 2, 7]
>>> values, counts = unique_counts(x)
>>> values
(0, 2, 3, 4, 7, 8)
>>> counts
(5, 2, 2, 1, 3, 1)