I have two MultiIndex dataframes that I'd like to combine into one.
I've tried to concat the two dataframes with pd.concat([df1, df2], axis=1, keys=('value_1', 'value_1')).swaplevel(1, 0, axis=1) but the resulting dataframe comes out like this:
product A B A B
v1 v2 v1 v2
date
2018-01-31 -0.123519 -0.113372 0.215493 0.025099
2018-02-28 -0.072106 -0.115016 -0.128000 0.006867
2018-03-31 0.008197 0.025000 0.396766 -0.028422
Where I was expecting an output like this
product A B
v1 v2 v1 v2
date
2018-01-31 -0.123519 -0.113372 0.215493 0.025099
2018-02-28 -0.072106 -0.115016 -0.128000 0.006867
2018-03-31 0.008197 0.025000 0.396766 -0.028422