Q:

pandas reset index of multi index dafaframe to a date value and convert the other indexes as columns

I have a multi index dataframe as shown below:
                                                                   number
location                   category         created_on  
Arab Republic of Egypt      ACCESS          2018-06-25 00:00:00        4
                            ACCOUNT         2018-04-24 04:00:00        3
                                            2018-05-31 04:00:00        3
                                            2018-06-28 00:00:00        3
                        ACTIVE DIRECTORY    2018-04-01 00:00:00        3
... ... ... ...
United States of America    WINDOWS 10      2018-09-25 04:00:00        8
                                            2018-09-25 08:00:00       13
                                            2018-09-26 08:00:00       12
                                            2018-09-27 08:00:00        8
                                            2018-09-27 12:00:00        9

I want to covert it to a dataframe with the date column as index but not lose the counts in the column number, the new dataframe should be something like this:
created_on              number       category       location
2018-06-25 00:00:00          4       ACCESS         Arab Republic of Egypt
2018-04-24 04:00:00          3       ACCOUNT        Arab Republic of Egypt
2018-05-31 04:00:00          3       ACCOUNT        Arab Republic of Egypt
2018-06-28 00:00:00          3       ACCOUNT        Arab Republic of Egypt
2018-04-01 00:00:00          3  ACTIVE DIRECTORY    Arab Republic of Egypt     
... ... ... ...
2018-09-25 04:00:00          8     WINDOWS 10       United States of America
2018-09-25 08:00:00         13     WINDOWS 10       United States of America
2018-09-26 08:00:00         12     WINDOWS 10       United States of America
2018-09-27 08:00:00          8     WINDOWS 10       United States of America
2018-09-27 12:00:00          9     WINDOWS 10       United States of America

How can I do this? 

A:

Use swaplevel on levels 0 and 2 and then use reset_index on levels 1 and 2:
df1 = df.swaplevel(0, 2).reset_index(level=[1, 2])

OR another idea first use reset_index then use set_index on column created_at:
df1 = df.reset_index().set_index('created_on')

Result:
print(df1)
                             category                  location  number
created_on                                                             
2018-06-25 00:00:00            ACCESS    Arab Republic of Egypt       4
2018-04-24 04:00:00           ACCOUNT    Arab Republic of Egypt       3
2018-05-31 04:00:00           ACCOUNT    Arab Republic of Egypt       3
2018-06-28 00:00:00           ACCOUNT    Arab Republic of Egypt       3
2018-04-01 00:00:00  ACTIVE DIRECTORY    Arab Republic of Egypt       3
...
2018-09-25 04:00:00        WINDOWS 10  United States of America       8
2018-09-25 08:00:00        WINDOWS 10  United States of America      13
2018-09-26 08:00:00        WINDOWS 10  United States of America      12
2018-09-27 08:00:00        WINDOWS 10  United States of America       8
2018-09-27 12:00:00        WINDOWS 10  United States of America       9

