pandas.Series.swaplevel

Series.swaplevel(i, j, copy=True)

Swap levels i and j in a MultiIndex

Parameters:

i, j : int, string (can be mixed)

Level of index to be swapped. Can pass level name as string.

Returns:

swapped : Series