使用外连接合并两个表。假设:
df1 = ['productID', 'Name']
df2 = ['userID', 'productID', 'usage']
我尝试使用 pandas 的 merge 函数进行外连接。
pd.merge(df1, df2[['userID','productID', 'usage']], on='productID', how = 'outer')
然而,我收到的错误消息是:
'productID' is both an index level and a column label, which is ambiguous.
我在谷歌上搜索了这个错误消息,并看到一个开放性 [issue]: https://github.com/facebook/prophet/issues/891
有解决方法吗?
set_index()
作为产品ID,要么重命名索引名称,要么删除相同的列并使用合并的left_index
/right_index
参数。 - anky