How do I merge the unique values in columns A
and B
from df
into list
?
id A B
1 x k
2 y x
3 x l
4 x k
This is what I am trying to achieve:
list = ['x', 'y', 'k', 'l']
Failed attempt:
list = df['A'].unique().tolist()
list.append(df['B'].unique())
The output:
['x', 'y', ['x', 'k', 'l']]