Consider two dataframes:
>>> X = pd.DataFrame(np.arange(0,12).reshape(4,3),columns=['a','b','c'])
>>> X
a b c
0 0 1 2
1 3 4 5
2 6 7 8
3 9 10 11
>>>
>>> Y = pd.DataFrame(np.array([['abc',22],['fgh',44],['ijk',0],['xee',99],['RGD',3]]),columns = ['x','y'])
>>> Y
x y
0 abc 22
1 fgh 44
2 ijk 0
3 xee 99
4 RGD 3
I want to join these two dataframes in a way such that I get the result
a b c
0 ijk 1 2
1 RGD 4 5
2 6 7 8
3 9 10 11
I have tried the following:
>>> X.loc[X['a'].astype(str).isin(Y['y']),'a']=Y[Y['y'].astype(str).isin(X['a'])]
>>> X
a b c
0 nan 1 2
1 nan 4 5
2 6.00 7 8
3 9.00 10 11
I think it is trying to match them index by index, giving me a nan. I have tried joining X and Y also but can't get that to work. I think merging the two dataframes would work but I don't know how to merge them on column 'a' and 'y' appropriately
Any tips here would be greatly appreciated

