I have a pandas dataframe that looks like this:
A B
Date a b c a b c
20180101 1 1 1 365 365 365
20180102 2 2 2 364 364 364
... ... ... ... ... ... ...
20181231 365 365 365 1 1 1
You can see I have a multilevel column index. However, I want to transform it into the following format:
a b c
Date Catelog1
20180101 A 1 1 1
B 365 365 365
20180102 A 2 2 2
B 364 364 364
... ... ... ... ...
20181231 A 365 365 365
B 1 1 1
However this is not obvious to me that how we can achieve this, moreover, what if I have more than two levels on the column axis and I only want to keep the one at the bottom and move all the above indexes on the row axis?