a_list = [1, 1, 2, 2, 3]a_set = set(a_list)number_of_unique_values = len(a_set)print(number_of_unique_values)
How do you find unique values in Python?
Using Python’s import numpy, the unique elements in the array are also obtained. In first step convert the list to x=numpy. array(list) and then use numpy. unique(x) function to get the unique values from the list.
How do you count unique values in a list?
- Select the range of cells, or make sure the active cell is in a table. …
- On the Data tab, in the Sort & Filter group, click Advanced. …
- Click Copy to another location.
- In the Copy to box, enter a cell reference. …
- Select the Unique records only check box, and click OK.