【发布时间】:2018-09-18 16:15:15
【问题描述】:
我有两个数据框 df1 df1 和 df2 df2 我想使用 python pandas 合并它们而不创建笛卡尔积。示例输出看起来像这样output 我应该怎么做?
目前,我正在使用 df3=pd.merge(df1,df2,on='id',how='left') 但它给了我叉积。结果数据帧 df3 包含 14 条记录 6 用于 id=1 和 8 用于 id=2。
谢谢,
【问题讨论】:
-
欢迎来到 StackOverflow!请不要在您的问题中使用图片。您可以阅读有关how to ask a question(尤其是how to create a good example)的信息,以获得良好的响应。