本文介绍了 pandas 合并给出错误“缓冲区具有错误的维数(预期为1,得到2)".的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试进行熊猫合并,并在尝试运行它时从标题中获取上述错误.我正在使用3列进行匹配,而在我仅对2列进行类似合并之前,它就可以正常工作.

I am trying to do a pandas merge and get the above error from the title when I try to run it. I am using 3 columns to match on whereas just before I do similar merge on only 2 columns and it works fine.

df = pd.merge(df, c, how="left",
        left_on=["section_term_ps_id", "section_school_id", "state"],
        right_on=["term_ps_id", "term_school_id", "state"])

两个数据框的列

df:

c:

是否可以像这样在三列上合并?这里的合并调用有什么问题吗?

Is it possible to merge on three columns like this? Is there anything wrong from the merge call here?

推荐答案

如注释中所述,您有一个dupe列:

As mentioned in the comments, you have a dupe column:

这篇关于 pandas 合并给出错误“缓冲区具有错误的维数(预期为1,得到2)".的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-22 13:54