I have 2 dataframes in my jupyter-notebook. In the first one I have a series with lists of words and in the second I have a series with words. I need to iterate over each list of words from the first dataframe, to check if the word is on the other dataframe, and make the cumulative sum.
a = pd.DataFrame({'text': [['one', 'two', 'three'], ['two', 'four'], ['five', 'one']], 'pos': [21,22,23], 'neg': [0,0,0]})
text pos neg
0 [one, two, three] 21 0
1 [two, four] 22 0
2 [five, one] 23 0
b = pd.DataFrame({'word': ['two', 'three', 'four'], 'pos': [100,200,300], 'neg': [1,2,3]})
word pos neg
0 two 100 1
1 three 200 2
2 four 300 3
So i would like to obtain this:
text pos neg
0 [one, two, three] 321 3
1 [two, four] 422 4
2 [five, one] 23 0
Thank you.