熊猫合并,加入加入列的问题

时间:2021-02-08 10:39:08

标签: python pandas join merge concatenation

我必须要大桌子 例如

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

1 个答案:

答案 0 :(得分:0)

可能的解决方案之一:

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

结果是:

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