I have a pandas dataframe like below:
pd.DataFrame({'col1': ['A', 'C'],
'col2': ['A', 'B'],
'col3': ['B', 'B'],
'col4': ['A', 'C'],
'col5': ['C', 'F'],
'col6': ['D', 'D'],
'col7': ['E', 'G'],
'col8': ['E', 'H'] })
col1 col2 col3 col4 col5 col6 col7 col8
A A B A C D E E
C B B C F D G H
I need to generate another dataframe where each row is the first three unique values of each row from previous dataframe.
so this is what I need.
fea1 fea2 fea3
A B C
C B F
I spent hours and was not able to find a solution. Does anyone know how to achieve that. Thanks a lot in advance.