Feb-20-2022, 06:55 PM
import pandas as pd df1 = pd.DataFrame({'Customer':['John Tom', 'Harry', 'Simon', 'Tom'], 'Supplier':['Harry', 'John Tom', 'Harry', 'Simon']}) for idx in df1: eseries = pd.Series(df1[idx]) print(f"df1[{idx}] unique = {eseries.unique()}")results:
Output:df1[Customer] unique = ['John Tom' 'Harry' 'Simon' 'Tom']
df1[Supplier] unique = ['Harry' 'John Tom' 'Simon']