finding unique numbers in array python code example
Example 1: return position of a unique value in python array
In [304]: array = np.array([1, 1, 2, 3, 2, 1, 2, 3])
In [305]: np.unique(array)
Out[305]: array([1, 2, 3])
In [306]: array == 1
Out[306]: array([ True, True, False, False, False, True, False, False])
In [307]: (array == 1).nonzero()[0]
Out[307]: array([0, 1, 5])
Example 2: count unique values in python
words = ['a', 'b', 'c', 'a']
unique_words = set(words)
unique_word_count = len(unique_words)