I am working with a Pivot Table in Pandas and I am facing an issue with the order of multi-level column headers.
Currently, I have the following column headers.

And, I want to reorder them to look like this

Is there any way to do this?
TIA!
I am working with a Pivot Table in Pandas and I am facing an issue with the order of multi-level column headers.
Currently, I have the following column headers.

And, I want to reorder them to look like this

Is there any way to do this?
TIA!
Use DataFrame.swaplevel with DataFrame.sort_index:
df = df.swaplevel(1, 0, axis=1).sort_index(axis=1)