Pandas: join DataFrames on field with different names?

前端 未结 2 1063
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-05 04:19

According to this documentation I can only make a join between fields having the same name.

Do you know if it\'s possible to join two DataFrames on a field having di

2条回答
  •  有刺的猬
    2020-12-05 04:37

    df2['id_key'] = df2['fk_key'].str.lower()

    df1['id_key'] = df1['id_key'].str.lower()

    Now try to merge the dataframes

    df3 = pd.merge(df2,df1,how='inner', on='id_key')

提交回复
热议问题