Pandas: how to merge two dataframes on a column by keeping the information of the first one?

后端 未结 2 765
没有蜡笔的小新
没有蜡笔的小新 2020-11-21 06:46

I have two dataframes df1 and df2. df1 contains the information of the age of people, while df2 contains the information

2条回答
  •  我在风中等你
    2020-11-21 07:18

    You can also use the join method:

    df1.set_index("Name").join(df2.set_index("Name"), how="left")
    

    edit: added set_index("Name")

提交回复
热议问题