I have two Dataframe's, let's call them df1 and df2.
df1
Term Served
term1 82321
term2 54232
term3 34323
term4 1231
df2
Full Term clicks
this is term1 233
oh boy this is term2 122
yea that's right term1 1121
oh no not that term4 313123
I would like to go row by row and find every time that the terms in df1 appear in df2. After that I would like to sum all of the clicks for that specific term. The out put would look like,
Term Served Clicks
term1 82321 1354
term2 54232 122
term3 34323 0
term4 1231 313123
Here is what I have so far. I haven't gotten past grabing all of the times that the terms in df1 appear in df2. The code below keeps looping through only the first row in df1. Maybe I am not understanding the str.findall()
or I have my loops wrong.
for index, row in df1.iterrows():
for row2 in df2.iteritems():
full_headline = df2['Full Term'].str.findall(row[0])
print(full_headline)