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

np.array

declare Numpy array

[1,1,2,1,2]

sample array

.unique(

returns unique values only from specified array

uniq

will contain array with unique values only