9951 explained code solutions for 126 technologies

python-numpyHow to get unique values from Numpy array

import numpy as np
a = np.array([1,1,2,1,2])
uniq = np.unique(a)ctrl + c
import numpy as np

load Numpy module for Python


declare Numpy array


sample array


returns unique values only from specified array


will contain array with unique values only