Reformat multi-index columns in dataframe

Viewed 25

I have a multi-index columns df as below

  stock1        stock2        stock3       
   price volume  price volume  price volume
0      1      2      3      4      5      6
1      2      3      4      5      6      7

I want to reformat it in such a way that it looks like below

df

   price                      volume           
   stock1 stock2 stock3 stock1 stock2 stock3
0      1      3      5      2      4      6
1      2      4      6      3      5      7

How can I achieve it in pandas.

Thanks

1 Answers
Related