NumPy unique set
import numpy as np numpy_array = np.array([3, 1, 2, 2, 3, 1]) unique_vals = np.unique(numpy_array) unique_vals #>>> array([1, 2, 3]) Note: results are sorted