Join/Merge two Pandas dataframes and use columns as multiindex

Viewed 2829

I have two dataframes with KPIs by date. I want to combine them and use multi-index so that each KPI can be easily compared to the other for the two df.

Like this:

concat dataframes and swap multiindex

I have tried to extract each KPI into a series, rename the series accordingly (df1, df2), and then concatenating them using the keys argument of pd.concat but it doesn't seem to work.

Any help would be greatly appreciated.

1 Answers
Related