我有两个数据帧:
df1
id frid title
1 1 abc
2 1 ddd
3 2 ghc
4 3 frg
5 1 def
df2
frid comment
1 w
2 s
3 e
现在我想基于frid
字段合并这两个数据帧。换句话说,我想将列comment
添加到df1
。我该怎么做?我知道join
命令,但它的工作方式不同(df1.join(df2)
)。你知道吗
结果应该是:
df
id frid title comment
1 1 abc w
2 1 ddd w
3 2 ghc s
4 3 frg e
5 1 def w
Tags:
使用^{} 并传递要合并的列,默认情况下,这将执行“内部”合并:
相关问题 更多 >
编程相关推荐