I have two data frames. For the sake of simpleness, I will provide two dummy data frames here.
A = pd.DataFrame({'id':[1,2,3], 'name':['a','b','c']})
B = pd.DataFrame({'id':[1,1,1,3,2,3,1]})
Now, I want to create a column on the data frame B with the names that match the ids. In this case, my desire output will be:
B = pd.DataFrame({'id':[1,1,1,3,2,3,1], 'name':['a','a','a','c','b','c','a'})
I was trying to use .apply
and lambda
or try to come up with other ideas, but I could not make it work.