def swaplevel(self, i=-<NUM_LIT:2>, j=-<NUM_LIT:1>):
new_levels = list(self.levels)<EOL>new_codes = list(self.codes)<EOL>new_names = list(self.names)<EOL>i = self._get_level_number(i)<EOL>j = self._get_level_number(j)<EOL>new_levels[i], new_levels[j] = new_levels[j], new_levels[i]<EOL>new_codes[i], new_codes[j] = new_codes[j], new_codes[i]<EOL>new_names[i], new_names[j] = new_names[j], new_names[i]<EOL>return MultiIndex(levels=new_levels, codes=new_codes,<EOL>names=new_names, verify_integrity=False)<EOL>
Swap level i with level j.

Calling this method does not change the ordering of the values.

Parameters
----------
i : int, str, default -2
    First level of index to be swapped. Can pass level name as string.
    Type of parameters can be mixed.
j : int, str, default -1
    Second level of index to be swapped. Can pass level name as string.
    Type of parameters can be mixed.

Returns
-------
MultiIndex
    A new MultiIndex.

.. versionchanged:: 0.18.1

   The indexes ``i`` and ``j`` are now optional, and default to
   the two innermost levels of the index.

See Also
--------
Series.swaplevel : Swap levels i and j in a MultiIndex.
Dataframe.swaplevel : Swap levels i and j in a MultiIndex on a
    particular axis.

Examples
--------
>>> mi = pd.MultiIndex(levels=[['a', 'b'], ['bb', 'aa']],
...                    codes=[[0, 0, 1, 1], [0, 1, 0, 1]])
>>> mi
MultiIndex(levels=[['a', 'b'], ['bb', 'aa']],
           codes=[[0, 0, 1, 1], [0, 1, 0, 1]])
>>> mi.swaplevel(0, 1)
MultiIndex(levels=[['bb', 'aa'], ['a', 'b']],
           codes=[[0, 1, 0, 1], [0, 0, 1, 1]])