I have these two DataFrames:
df1
A B
0 8 x
1 3 y
2 1 x
3 2 z
4 7 y
and
df2
A B
0 x hey
1 y there
2 z sir
I am trying to append df1['B'] based on df2['B'] so that my desired output would be:
df3
A B
0 8 hey
1 3 there
2 1 hey
3 2 sir
4 7 there
Is there a built in method for doing this kind of transformation? I was experimenting with something similar to this, but I could not get it to function properly:
for x in df1['B']:
if df2['A'] == x:
df1['B'].append.df2['B']