In [304]: array = np.array([1, 1, 2, 3, 2, 1, 2, 3])
In [305]: np.unique(array) # unique values in `array`
Out[305]: array([1, 2, 3])
In [306]: array == 1 # retrieve a boolean mask where elements are equal to 1
Out[306]: array([ True, True, False, False, False, True, False, False])
In [307]: (array == 1).nonzero()[0] # get the `True` indices for the operation above
Out[307]: array([0, 1, 5])
import numpy as np
np.unique([1,6,6,2,2,3,4,5,5,5], return_index=True)
>>> (array([1, 2, 3, 4, 5, 6]), array([0, 3, 5, 6, 7, 1], dtype=int64))