Pandas join issue: columns overlap but no suffix specified

后端 未结 4 1389
慢半拍i
慢半拍i 2020-12-02 06:56

I have following 2 data frames:

df_a =

     mukey  DI  PI
0   100000  35  14
1  1000005  44  14
2  1000006  44  14
3  1000007  43  13
4  1000008  43  13

df         


        
4条回答
  •  情书的邮戳
    2020-12-02 07:36

    The .join() function is using the index of the passed as argument dataset, so you should use set_index or use .merge function instead.

    Please find the two examples that should work in your case:

    join_df = LS_sgo.join(MSU_pi.set_index('mukey'), on='mukey', how='left')
    

    or

    join_df = df_a.merge(df_b, on='mukey', how='left')
    

提交回复
热议问题