Regrouping pandas multiindex columns

Viewed 1179

I am running into an issue where adding new columns to a multiindex column DataFrame causes the new columns to append to the end of the DataFrame. E.g.:

Group 1         | Group 2        | Group 1 | Group 2 |
------------------------------------------------------
Sub 1  | Sub 2  | Sub 1  | Sub 2 | New Sub | New Sub |

Whereas what I want is:

Group 1                   | Group 2                  |
------------------------------------------------------
Sub 1  | Sub 2  | New Sub | Sub 1  | Sub 2 | New Sub |

Is there a way to re-group/order my multiindex to do this? Note- I do not want to re-order the Sub Groups by name, as New Sub needs to go at the end, and alphabetically might not sort correctly.

2 Answers
Related