1import numpy as np
2
3x = np.array([1,1,1,2,2,2,5,25,1,1])
4unique, counts = np.unique(x, return_counts=True)
5
6print np.asarray((unique, counts)).T
1number_list = numpy.array([1, 1, 2, 3, 4, 4, 1])
2(unique, counts) = numpy.unique(number_list, return_counts=True)
1>>> a = np.array(['a', 'b', 'b', 'c', 'a'])
2>>> u, indices = np.unique(a, return_index=True)
3>>> u
4array(['a', 'b', 'c'], dtype='<U1')
5>>> indices
6array([0, 1, 3])
7>>> a[indices]
8array(['a', 'b', 'c'], dtype='<U1')
9