源码

首页 » 归档 » 源码 » python – pandas:在多列上合并(连接)两个数…

python – pandas:在多列上合并(连接)两个数…


我正在尝试使用两列连接两个pandas数据帧:

new_df = pd.merge(A_df, B_df,  how='left', left_on='[A_c1,c2]', right_on = '[B_c1,c2]')

但得到以下错误:

pandas/index.pyx in pandas.index.IndexEngine.get_loc (pandas/index.c:4164)()

pandas/index.pyx in pandas.index.IndexEngine.get_loc (pandas/index.c:4028)()

pandas/src/hashtable_class_helper.pxi in pandas.hashtable.PyObjectHashTable.get_item (pandas/hashtable.c:13166)()

pandas/src/hashtable_class_helper.pxi in pandas.hashtable.PyObjectHashTable.get_item (pandas/hashtable.c:13120)()

KeyError: '[B_1, c2]'

知道应该采取什么样的正确方法吗?谢谢!

(0)

本文由 投稿者 创作,文章地址:https://blog.isoyu.com/archives/python-pandaszaiduolieshanghebinglianjielianggeshu.html
采用知识共享署名4.0 国际许可协议进行许可。除注明转载/出处外,均为本站原创或翻译,转载前请务必署名。最后编辑时间为:9 月 19, 2019 at 01:23 下午

热评文章