合并两个 DataFrame - 多索引 ValueError

Merging two DataFrames - Multi-index ValueError

我想合并两个 DataFrame,如下所示:

df
                a        b         c           d        e        f
date                                                                  
2006-01-01  0.004503  0.006280  0.001777 -0.010202 -0.067004  0.062179
2006-01-02  0.004496  0.039818  0.035322  0.033956  0.017256 -0.024769
2006-01-03  0.004496  0.019632  0.015137 -0.008447 -0.061254  0.025879

df1

x              g        h         i         j          k         l
date                                                                  
2006-01-01  0.000001  0.000001  0.000001 -0.000001 -0.000001  0.000001
2006-01-02  0.000001  0.000001  0.000001  0.000001  0.000001 -0.000001
2006-01-03  0.000001  0.000001  0.000001 -0.000001 -0.000001  0.000001

我尝试过合并:

dflist = [df, df1]
df2 = reduce(lambda  left,right: pd.merge(left,right,on=['date'],
                                            how='outer'), dflist)

但是,它returns出现以下错误:

ValueError: The column label 'date' is not unique.
For a multi-index, the label must be a tuple with elements corresponding to each level.

任何解决此问题的帮助都很棒!

最简单的解决方案是加入:

df2 = df.join(df1)

我自己解决的问题:

df2 = pd.merge(df, df1,left_index=True, right_index=True )