【问题标题】:Pandas merge, join Problem with joining column [duplicate]熊猫合并,加入加入列的问题[重复]
【发布时间】:2021-05-11 23:06:07
【问题描述】:

我必须要大桌子 例如

df1 = 
Name Age
Alex 20
Bob  19
Don  56

df2 =
Name PL
Don  Python
Bob  C
Alex java

我想得到

df3 = 
Name Age PL
Alex 20  Java
Bob  19  C
Don  56  Python

【问题讨论】:

标签: python pandas join merge concatenation


【解决方案1】:

一种可能的解决方案:

df3 = pd.merge(df1, df2, on='Name')

结果是:

   Name  Age      PL
0  Alex   20    Java
1   Bob   19       C
2   Don   56  Python

【讨论】:

    猜你喜欢
    • 2023-02-04
    • 2021-12-19
    • 2019-01-02
    • 1970-01-01
    • 2014-12-26
    • 2022-01-23
    • 2014-09-21
    • 2016-04-23
    • 2023-03-15
    相关资源
    最近更新 更多