Let's say I have two data frames-
dic = {'firstname':['John','Jacob','Jim','Matt','David','Susan','Karen',
'Linda','Pam','Rachel'],
'lastname':['Smith','Jones','Miller','White','Johnson','Wilson',
'Wilkins','Parker','Cunningham','Ray'],
'company':['KFC','BK','MCD','KFC','WND','CFA','CHP','TB','INO','TB']}
df = pd.DataFrame(dic)
print(df)
with output-
firstname lastname company
0 John Smith KFC
1 Jacob Jones BK
2 Jim Miller MCD
3 Matt White KFC
4 David Johnson WND
5 Susan Wilson CFA
6 Karen Wilkins CHP
7 Linda Parker TB
8 Pam Cunningham INO
9 Rachel Ray TB
and
dic2 = {'workplace':['BLB','RDB','CFA','STB','DNK','ENP','TB','SHZ','JJ','SUB']}
df2 = pd.DataFrame(dic2)
print(df2)
with output-
workplace
0 BLB
1 RDB
2 CFA
3 STB
4 DNK
5 ENP
6 TB
7 SHZ
8 JJ
9 SUB
My goal is to find if any values in the workplace column from df2 match with the company column from df1.
Any ideas? Feel free to solve any way, a possible output could simply be-
firstname lastname company matched
0 John Smith KFC False
1 Jacob Jones BK False
2 Jim Miller MCD False
3 Matt White KFC False
4 David Johnson WND False
5 Susan Wilson CFA True
6 Karen Wilkins CHP False
7 Linda Parker TB True
8 Pam Cunningham INO False
9 Rachel Ray TB True