I have 2 dataframes with the data as below:
df1:
====
id name age likes
--- ----- ---- -----
0 A 21 rose
1 B 22 apple
2 C 30 grapes
4 D 21 lily
df2:
====
category Fruit Flower
--------- ------- -------
orange 1 0
apple 1 0
rose 0 1
lily 0 1
grapes 1 0
What I am trying to do is add another column to df1 which would contain the word 'Fruit' or 'Flower' depending on the one-hot encoding in df2 for that entry. I am looking for a purely pandas/numpy implementation.
Any help would be appreciated.
Thanks!