Regarding this df:
Amount type
Month_year 2019-06-01 2019-07-01 2019-06-01 2019-07-01
TYPE_ID 1 2 1 2 1 2 1 2
ID
100 20 10 40 20 1 1 2 1
200 80 60 30 10 2 2 1 1
The following code:
df = df.sort_index(axis=1, level=[1,2])
produces this:
Amount type Amount ... type Amount type
Month_year 2019-06-01 2019-06-01 2019-06-01 ... 2019-07-01 2019-07-01 2019-07-01
TYPE_ID 1 1 2 ... 1 2 2
ID ...
100 20 1 10 ... 2 20 1
200 80 2 60 ... 1 10 1
I really don't understand what's going on. I've read the docs but there are no examples and the description is really obscure.
Could anyone explain to me how this method works and how I received this result?


axis = 0, sort by the index