【发布时间】:2019-05-01 21:44:35
【问题描述】:
我想在 pandas 中连接这两个数据帧。
df1:
Month Date ID
12 01 01
12 01 02
12 02 03
12 02 01
df2:
ID Name
01 Jack
02 Lu
03 James
新的df:
Month Date ID Name
12 01 01 Jack
12 01 02 Lu
12 02 03 James
12 02 01 Jack
谁能帮我解决这个问题? 在此处查看清晰的表格:enter image description here
【问题讨论】:
-
您正在寻找合并,df1.merge(df2)。它是重复的
-
pd.merge(df1,df2, how='left', on=['ID'])