【发布时间】:2023-04-06 23:59:01
【问题描述】:
我正在尝试连接两个数据帧 df1 和 df2:
输入
name age hobby married
index
0 jack 20 hockey yes
1 ben 19 chess no
2 lisa 30 golf no
name age hobby job
index
0 jack 20 hockey student
1 anna 34 football finance
2 dan 26 golf retail
我想在多个列上匹配,所以假设['name', 'age'],得到df:
输出
name age hobby married job
index
0 jack 20 hockey yes student
1 ben 19 chess no /
2 lisa 30 golf no /
3 anna 34 football / finance
4 dan 26 golf / retail
是否可以通过使用 concat 来做到这一点?因为我不知道如何匹配键列表以避免重叠行...
【问题讨论】:
标签: python pandas dataframe merge concat