【发布时间】:2020-01-11 07:44:11
【问题描述】:
使用外连接合并两个表。比方说
df1 = ['productID', 'Name']
df2 = ['userID', 'productID', 'usage']
我尝试在 pandas 中使用外连接和合并功能。
pd.merge(df1, df2[['userID','productID', 'usage']], on='productID', how = 'outer')
但是,我收到的错误消息是
'productID' is both an index level and a column label, which is ambiguous.
我用谷歌搜索了这条错误消息,看到了一个开放的 [问题]:https://github.com/facebook/prophet/issues/891
我的问题有什么解决办法吗?
【问题讨论】:
-
'productID' is both an index level and a column label, which is ambiguous表示您的索引是productID和一列,可能是您将set_index()作为任一数据帧上的产品 ID,重命名索引名称或删除同一列并使用 @987654328 @/right_index合并参数 -
谢谢@anky_91。下面的答案解决了我的问题。
标签: python pandas jupyter-notebook