I have some trouble with my dataframe comparison. What I have are two dataframes, the first has tokenised words.
df_1:
id sentence some more info
1 [I, am, happy] bla
2 [I, am, happier] bla
3 [I, am, the, saddest] bla
and
df_2:
id word more most
1 happy happier happiest
2 sad sadder saddest
What I want to do is compare the two dataframes and if a word in df_1 matches a word anywhere in df_2 that it will be changed to df_2['word'] in the row of the corresponding word. So my output would look something like this:
df_1
id sentence some more info new_sentence
1 [I, am, happy] bla [I, am, happy]
2 [I, am, happier] bla [I, am, happy]
3 [I, am, the, saddest] bla [I, am, the, sad]
I have tried some things using .compare() and writing a function, but nothing has seemed to work so far.
Thanks for your help in advance!