MultiIndex.
swaplevel
Swap level i with level j. Calling this method does not change the ordering of the values.
First level of index to be swapped. Can pass level name as string. Parameter types can be mixed.
Second level of index to be swapped. Can pass level name as string. Parameter types can be mixed.
A new MultiIndex.
Examples
>>> midx = ps.MultiIndex.from_arrays([['a', 'b'], [1, 2]], names = ['word', 'number']) >>> midx MultiIndex([('a', 1), ('b', 2)], names=['word', 'number'])
>>> midx.swaplevel(0, 1) MultiIndex([(1, 'a'), (2, 'b')], names=['number', 'word'])
>>> midx.swaplevel('number', 'word') MultiIndex([(1, 'a'), (2, 'b')], names=['number', 'word'])