Following up from this question
I got a datframe after pivoting like this .
AVG GrossProfit AVG PMV Loss% Sales
Use swaplevel with sort_index for sorting MultiIndex:
MultiIndex
df = df.swaplevel(0,1, axis=1).sort_index(axis=1) print (df) ParentAuction Copart IAA \ AVG GrossProfit AVG PMV Loss% Sales AVG GrossProfit AVG PMV Make Acura 112.99 -15.53 36.46 96.0 NaN NaN ParentAuction Loss% Sales Make Acura NaN NaN