def swaplevel(self, i: Union[(int, Name)]=(- 2), j: Union[(int, Name)]=(- 1), axis: Axis=0) -> 'DataFrame':
    "\n        Swap levels i and j in a MultiIndex on a particular axis.\n\n        Parameters\n        ----------\n        i, j : int or str\n            Levels of the indices to be swapped. Can pass level name as string.\n        axis : {0 or 'index', 1 or 'columns'}, default 0\n            The axis to swap levels on. 0 or 'index' for row-wise, 1 or\n            'columns' for column-wise.\n\n        Returns\n        -------\n        DataFrame\n            DataFrame with levels swapped in MultiIndex.\n\n        Examples\n        --------\n        >>> midx = pd.MultiIndex.from_arrays(\n        ...     [['red', 'blue'], [1, 2], ['s', 'm']], names = ['color', 'number', 'size'])\n        >>> midx  # doctest: +SKIP\n        MultiIndex([( 'red', 1, 's'),\n                    ('blue', 2, 'm')],\n                   names=['color', 'number', 'size'])\n\n        Swap levels in a MultiIndex on index.\n\n        >>> psdf = ps.DataFrame({'x': [5, 6], 'y':[5, 6]}, index=midx)\n        >>> psdf  # doctest: +NORMALIZE_WHITESPACE\n                           x  y\n        color number size\n        red   1      s     5  5\n        blue  2      m     6  6\n\n        >>> psdf.swaplevel()  # doctest: +NORMALIZE_WHITESPACE\n                           x  y\n        color size number\n        red   s    1       5  5\n        blue  m    2       6  6\n\n        >>> psdf.swaplevel(0, 1)  # doctest: +NORMALIZE_WHITESPACE\n                           x  y\n        number color size\n        1      red   s     5  5\n        2      blue  m     6  6\n\n        >>> psdf.swaplevel('number', 'size')  # doctest: +NORMALIZE_WHITESPACE\n                           x  y\n        color size number\n        red   s    1       5  5\n        blue  m    2       6  6\n\n        Swap levels in a MultiIndex on columns.\n\n        >>> psdf = ps.DataFrame({'x': [5, 6], 'y':[5, 6]})\n        >>> psdf.columns = midx\n        >>> psdf\n        color  red blue\n        number   1    2\n        size     s    m\n        0        5    5\n        1        6    6\n\n        >>> psdf.swaplevel(axis=1)\n        color  red blue\n        size     s    m\n        number   1    2\n        0        5    5\n        1        6    6\n\n        >>> psdf.swaplevel(axis=1)\n        color  red blue\n        size     s    m\n        number   1    2\n        0        5    5\n        1        6    6\n\n        >>> psdf.swaplevel(0, 1, axis=1)\n        number   1    2\n        color  red blue\n        size     s    m\n        0        5    5\n        1        6    6\n\n        >>> psdf.swaplevel('number', 'color', axis=1)\n        number   1    2\n        color  red blue\n        size     s    m\n        0        5    5\n        1        6    6\n        "
    axis = validate_axis(axis)
    if (axis == 0):
        internal = self._swaplevel_index(i, j)
    else:
        assert (axis == 1)
        internal = self._swaplevel_columns(i, j)
    return DataFrame(internal)
Swap levels i and j in a MultiIndex on a particular axis.

Parameters
----------
i, j : int or str
    Levels of the indices to be swapped. Can pass level name as string.
axis : {0 or 'index', 1 or 'columns'}, default 0
    The axis to swap levels on. 0 or 'index' for row-wise, 1 or
    'columns' for column-wise.

Returns
-------
DataFrame
    DataFrame with levels swapped in MultiIndex.

Examples
--------
>>> midx = pd.MultiIndex.from_arrays(
...     [['red', 'blue'], [1, 2], ['s', 'm']], names = ['color', 'number', 'size'])
>>> midx  # doctest: +SKIP
MultiIndex([( 'red', 1, 's'),
            ('blue', 2, 'm')],
           names=['color', 'number', 'size'])

Swap levels in a MultiIndex on index.

>>> psdf = ps.DataFrame({'x': [5, 6], 'y':[5, 6]}, index=midx)
>>> psdf  # doctest: +NORMALIZE_WHITESPACE
                   x  y
color number size
red   1      s     5  5
blue  2      m     6  6

>>> psdf.swaplevel()  # doctest: +NORMALIZE_WHITESPACE
                   x  y
color size number
red   s    1       5  5
blue  m    2       6  6

>>> psdf.swaplevel(0, 1)  # doctest: +NORMALIZE_WHITESPACE
                   x  y
number color size
1      red   s     5  5
2      blue  m     6  6

>>> psdf.swaplevel('number', 'size')  # doctest: +NORMALIZE_WHITESPACE
                   x  y
color size number
red   s    1       5  5
blue  m    2       6  6

Swap levels in a MultiIndex on columns.

>>> psdf = ps.DataFrame({'x': [5, 6], 'y':[5, 6]})
>>> psdf.columns = midx
>>> psdf
color  red blue
number   1    2
size     s    m
0        5    5
1        6    6

>>> psdf.swaplevel(axis=1)
color  red blue
size     s    m
number   1    2
0        5    5
1        6    6

>>> psdf.swaplevel(axis=1)
color  red blue
size     s    m
number   1    2
0        5    5
1        6    6

>>> psdf.swaplevel(0, 1, axis=1)
number   1    2
color  red blue
size     s    m
0        5    5
1        6    6

>>> psdf.swaplevel('number', 'color', axis=1)
number   1    2
color  red blue
size     s    m
0        5    5
1        6    6
def swaplevel(self, i: Union[(int, Name)]=(- 2), j: Union[(int, Name)]=(- 1), axis: Axis=0) -> 'DataFrame':
    "\n        Swap levels i and j in a MultiIndex on a particular axis.\n\n        Parameters\n        ----------\n        i, j : int or str\n            Levels of the indices to be swapped. Can pass level name as string.\n        axis : {0 or 'index', 1 or 'columns'}, default 0\n            The axis to swap levels on. 0 or 'index' for row-wise, 1 or\n            'columns' for column-wise.\n\n        Returns\n        -------\n        DataFrame\n            DataFrame with levels swapped in MultiIndex.\n\n        Examples\n        --------\n        >>> midx = pd.MultiIndex.from_arrays(\n        ...     [['red', 'blue'], [1, 2], ['s', 'm']], names = ['color', 'number', 'size'])\n        >>> midx  # doctest: +SKIP\n        MultiIndex([( 'red', 1, 's'),\n                    ('blue', 2, 'm')],\n                   names=['color', 'number', 'size'])\n\n        Swap levels in a MultiIndex on index.\n\n        >>> psdf = ps.DataFrame({'x': [5, 6], 'y':[5, 6]}, index=midx)\n        >>> psdf  # doctest: +NORMALIZE_WHITESPACE\n                           x  y\n        color number size\n        red   1      s     5  5\n        blue  2      m     6  6\n\n        >>> psdf.swaplevel()  # doctest: +NORMALIZE_WHITESPACE\n                           x  y\n        color size number\n        red   s    1       5  5\n        blue  m    2       6  6\n\n        >>> psdf.swaplevel(0, 1)  # doctest: +NORMALIZE_WHITESPACE\n                           x  y\n        number color size\n        1      red   s     5  5\n        2      blue  m     6  6\n\n        >>> psdf.swaplevel('number', 'size')  # doctest: +NORMALIZE_WHITESPACE\n                           x  y\n        color size number\n        red   s    1       5  5\n        blue  m    2       6  6\n\n        Swap levels in a MultiIndex on columns.\n\n        >>> psdf = ps.DataFrame({'x': [5, 6], 'y':[5, 6]})\n        >>> psdf.columns = midx\n        >>> psdf\n        color  red blue\n        number   1    2\n        size     s    m\n        0        5    5\n        1        6    6\n\n        >>> psdf.swaplevel(axis=1)\n        color  red blue\n        size     s    m\n        number   1    2\n        0        5    5\n        1        6    6\n\n        >>> psdf.swaplevel(axis=1)\n        color  red blue\n        size     s    m\n        number   1    2\n        0        5    5\n        1        6    6\n\n        >>> psdf.swaplevel(0, 1, axis=1)\n        number   1    2\n        color  red blue\n        size     s    m\n        0        5    5\n        1        6    6\n\n        >>> psdf.swaplevel('number', 'color', axis=1)\n        number   1    2\n        color  red blue\n        size     s    m\n        0        5    5\n        1        6    6\n        "
    axis = validate_axis(axis)
    if (axis == 0):
        internal = self._swaplevel_index(i, j)
    else:
        assert (axis == 1)
        internal = self._swaplevel_columns(i, j)
    return DataFrame(internal)