I would like to get this result from these two DataFrames
df1 = pd.DataFrame({'url': [
'http://google.com/men',
'http://google.com/women',
'http://google.com/men-shoes',
'http://google.com/women-shoes',
'http://google.com/not-important',
], 'click': [3, 4, 6, 5, 8]})
df2 = pd.DataFrame({'keyword': ['men','women','shoes', 'kids']})
Result:
keyword instances clicks
0 men 2 9.0
1 women 2 9.0
2 shoes 2 11.0
3 kids 0 0.0
Which is basically counting how many times any df2
keywords appears on any df1
url
column then merge to check those rows for a cumulative sum of click
column on df1
I am struggling to get this result, thanks.