Joining two pandas dataframes based on multiple conditions

前端 未结 2 1798
滥情空心
滥情空心 2021-01-05 00:54

df_a and df_b are two dataframes that looks like following

df_a
A   B       C      D     E
x1  Apple   0.3   0.9    0.6
x1  Orange          


        
2条回答
  •  暖寄归人
    2021-01-05 01:22

    You can still achieve this with a left join which is very ideal.
    See below:

    final_df = pd.merge(df_a, df_b[['A', 'B_new','F']], how="left", left_on=['A', 'B'], right_on=['A', 'B_new']);
    

提交回复
热议问题