xxxxxxxxxx
sample_list = [10, 20, 10]
unique_values = (list(set(sample_list)))
xxxxxxxxxx
# just turn it into a set and then convert again into a list
res = list(set(lst1)))
# now check the lengths of the two lists
print(len(res))
print(len(lst1))
xxxxxxxxxx
# Method 1 = convert to set to remove duplicate and then convert back to list
mylist = list(set(mylist))
# Method 2 = use numpy to convert list to array and the apply unique method
np.unique(np.array(mylist)) # You can change the array back to list
# Method 3 = For pandas dataframe
df["col"].unique()
xxxxxxxxxx
original = ['a', 'b', 'a']
non_duplicates = list(set(original))
print(non_duplicates)