Find equal columns between two dataframes

后端 未结 4 1106
迷失自我
迷失自我 2020-12-29 06:49

I have two pandas data frames, a and b:

a1   a2   a3   a4   a5   a6   a7
1    3    4    5    3    4    5
0    2    0           


        
4条回答
  •  萌比男神i
    2020-12-29 07:03

    One way of merge

    s=df1.T.reset_index().merge(df2.T.assign(match=lambda x : x.index))
    dict(zip(s['index'],s['match']))
    {'a1': 'b5', 'a2': 'b7', 'a3': 'b6', 'a4': 'b4', 'a5': 'b1', 'a6': 'b3', 'a7': 'b2'}
    

提交回复
热议问题