I have one dataframe
#Around 100000 rows
df = pd.DataFrame({'text': [ 'Apple is healthy', 'Potato is round', 'Apple might be green'],
'category': ["","", ""],
})
A second dataframe
#Around 3000 rows
df_2 = pd.DataFrame({'keyword': [ 'Apple ', 'Potato'],
'category': ["fruit","vegetable"],
})
The required result
#Around 100000 rows
df = pd.DataFrame({'text': [ 'Apple is healthy', 'Potato is round', 'Apple might be green'],
'category': ["fruit","vegetable", "fruit"],
})
I tried this currently
df.set_index('text')
df_2.set_index('keyword')
df.update(df_2)
The result is
text category
Apple is healthy fruit
Potato is round vegetable
Apple might be green
AS you can see it does not add category for last row. How can I achieve that?