I have a DataFrame df1 that looks like this:
df1
A B C ----------------- 1 1 2 2 2 3 5 4 9
list(map(set,df.values)) Out[72]: [{1, 2}, {2, 3}, {4, 5, 9}]
In [88]: df.stack().groupby(level=0).apply(lambda x: x.unique().tolist()) Out[88]: 0 [1, 2] 1 [2, 3] 2 [5, 4, 9] dtype: object
Lets use pd.unique i.e
pd.unique
df.T.agg([pd.unique]) 0 1 2 unique [1, 2] [2, 3] [5, 4, 9]