def rename_axis(self, mapper: Union[(Any, Sequence[Any], Dict[(Name, Any)], Callable[([Name], Any)])]=None, index: Union[(Any, Sequence[Any], Dict[(Name, Any)], Callable[([Name], Any)])]=None, columns: Union[(Any, Sequence[Any], Dict[(Name, Any)], Callable[([Name], Any)])]=None, axis: Optional[Axis]=0, inplace: Optional[bool]=False) -> Optional['DataFrame']:
    '\n        Set the name of the axis for the index or columns.\n\n        Parameters\n        ----------\n        mapper : scalar, list-like, optional\n            A scalar, list-like, dict-like or functions transformations to\n            apply to the axis name attribute.\n        index, columns : scalar, list-like, dict-like or function, optional\n            A scalar, list-like, dict-like or functions transformations to\n            apply to that axis\' values.\n\n            Use either ``mapper`` and ``axis`` to\n            specify the axis to target with ``mapper``, or ``index``\n            and/or ``columns``.\n        axis : {0 or \'index\', 1 or \'columns\'}, default 0\n            The axis to rename.\n        inplace : bool, default False\n            Modifies the object directly, instead of creating a new DataFrame.\n\n        Returns\n        -------\n        DataFrame, or None if `inplace` is True.\n\n        See Also\n        --------\n        Series.rename : Alter Series index labels or name.\n        DataFrame.rename : Alter DataFrame index labels or name.\n        Index.rename : Set new names on index.\n\n        Notes\n        -----\n        ``DataFrame.rename_axis`` supports two calling conventions\n\n        * ``(index=index_mapper, columns=columns_mapper, ...)``\n        * ``(mapper, axis={\'index\', \'columns\'}, ...)``\n\n        The first calling convention will only modify the names of\n        the index and/or the names of the Index object that is the columns.\n\n        The second calling convention will modify the names of the\n        corresponding index specified by axis.\n\n        We *highly* recommend using keyword arguments to clarify your\n        intent.\n\n        Examples\n        --------\n        >>> df = ps.DataFrame({"num_legs": [4, 4, 2],\n        ...                    "num_arms": [0, 0, 2]},\n        ...                   index=["dog", "cat", "monkey"],\n        ...                   columns=["num_legs", "num_arms"])\n        >>> df\n                num_legs  num_arms\n        dog            4         0\n        cat            4         0\n        monkey         2         2\n\n        >>> df = df.rename_axis("animal").sort_index()\n        >>> df  # doctest: +NORMALIZE_WHITESPACE\n                num_legs  num_arms\n        animal\n        cat            4         0\n        dog            4         0\n        monkey         2         2\n\n        >>> df = df.rename_axis("limbs", axis="columns").sort_index()\n        >>> df # doctest: +NORMALIZE_WHITESPACE\n        limbs   num_legs  num_arms\n        animal\n        cat            4         0\n        dog            4         0\n        monkey         2         2\n\n        **MultiIndex**\n\n        >>> index = pd.MultiIndex.from_product([[\'mammal\'],\n        ...                                     [\'dog\', \'cat\', \'monkey\']],\n        ...                                    names=[\'type\', \'name\'])\n        >>> df = ps.DataFrame({"num_legs": [4, 4, 2],\n        ...                    "num_arms": [0, 0, 2]},\n        ...                   index=index,\n        ...                   columns=["num_legs", "num_arms"])\n        >>> df  # doctest: +NORMALIZE_WHITESPACE\n                       num_legs  num_arms\n        type   name\n        mammal dog            4         0\n               cat            4         0\n               monkey         2         2\n\n        >>> df.rename_axis(index={\'type\': \'class\'}).sort_index()  # doctest: +NORMALIZE_WHITESPACE\n                       num_legs  num_arms\n        class  name\n        mammal cat            4         0\n               dog            4         0\n               monkey         2         2\n\n        >>> df.rename_axis(index=str.upper).sort_index()  # doctest: +NORMALIZE_WHITESPACE\n                       num_legs  num_arms\n        TYPE   NAME\n        mammal cat            4         0\n               dog            4         0\n               monkey         2         2\n        '

    def gen_names(v: Union[(Any, Sequence[Any], Dict[(Name, Any)], Callable[([Name], Any)])], curnames: List[Name]) -> List[Label]:
        newnames: List[Name]
        if is_scalar(v):
            newnames = [cast(Name, v)]
        elif (is_list_like(v) and (not is_dict_like(v))):
            newnames = list(cast(Sequence[Name], v))
        elif is_dict_like(v):
            v_dict = cast(Dict[(Name, Name)], v)
            newnames = [(v_dict[name] if (name in v_dict) else name) for name in curnames]
        elif callable(v):
            v_callable = cast(Callable[([Name], Name)], v)
            newnames = [v_callable(name) for name in curnames]
        else:
            raise ValueError('`mapper` or `index` or `columns` should be either dict-like or function type.')
        if (len(newnames) != len(curnames)):
            raise ValueError('Length of new names must be {}, got {}'.format(len(curnames), len(newnames)))
        return [(name if is_name_like_tuple(name) else (name,)) for name in newnames]
    if ((mapper is not None) and ((index is not None) or (columns is not None))):
        raise TypeError("Cannot specify both 'mapper' and any of 'index' or 'columns'.")
    if (mapper is not None):
        axis = validate_axis(axis)
        if (axis == 0):
            index = mapper
        elif (axis == 1):
            columns = mapper
    column_label_names = (gen_names(columns, self.columns.names) if (columns is not None) else self._internal.column_label_names)
    index_names = (gen_names(index, self.index.names) if (index is not None) else self._internal.index_names)
    internal = self._internal.copy(index_names=index_names, column_label_names=column_label_names)
    if inplace:
        self._update_internal_frame(internal)
        return None
    else:
        return DataFrame(internal)
Set the name of the axis for the index or columns.

Parameters
----------
mapper : scalar, list-like, optional
    A scalar, list-like, dict-like or functions transformations to
    apply to the axis name attribute.
index, columns : scalar, list-like, dict-like or function, optional
    A scalar, list-like, dict-like or functions transformations to
    apply to that axis' values.

    Use either ``mapper`` and ``axis`` to
    specify the axis to target with ``mapper``, or ``index``
    and/or ``columns``.
axis : {0 or 'index', 1 or 'columns'}, default 0
    The axis to rename.
inplace : bool, default False
    Modifies the object directly, instead of creating a new DataFrame.

Returns
-------
DataFrame, or None if `inplace` is True.

See Also
--------
Series.rename : Alter Series index labels or name.
DataFrame.rename : Alter DataFrame index labels or name.
Index.rename : Set new names on index.

Notes
-----
``DataFrame.rename_axis`` supports two calling conventions

* ``(index=index_mapper, columns=columns_mapper, ...)``
* ``(mapper, axis={'index', 'columns'}, ...)``

The first calling convention will only modify the names of
the index and/or the names of the Index object that is the columns.

The second calling convention will modify the names of the
corresponding index specified by axis.

We *highly* recommend using keyword arguments to clarify your
intent.

Examples
--------
>>> df = ps.DataFrame({"num_legs": [4, 4, 2],
...                    "num_arms": [0, 0, 2]},
...                   index=["dog", "cat", "monkey"],
...                   columns=["num_legs", "num_arms"])
>>> df
        num_legs  num_arms
dog            4         0
cat            4         0
monkey         2         2

>>> df = df.rename_axis("animal").sort_index()
>>> df  # doctest: +NORMALIZE_WHITESPACE
        num_legs  num_arms
animal
cat            4         0
dog            4         0
monkey         2         2

>>> df = df.rename_axis("limbs", axis="columns").sort_index()
>>> df # doctest: +NORMALIZE_WHITESPACE
limbs   num_legs  num_arms
animal
cat            4         0
dog            4         0
monkey         2         2

**MultiIndex**

>>> index = pd.MultiIndex.from_product([['mammal'],
...                                     ['dog', 'cat', 'monkey']],
...                                    names=['type', 'name'])
>>> df = ps.DataFrame({"num_legs": [4, 4, 2],
...                    "num_arms": [0, 0, 2]},
...                   index=index,
...                   columns=["num_legs", "num_arms"])
>>> df  # doctest: +NORMALIZE_WHITESPACE
               num_legs  num_arms
type   name
mammal dog            4         0
       cat            4         0
       monkey         2         2

>>> df.rename_axis(index={'type': 'class'}).sort_index()  # doctest: +NORMALIZE_WHITESPACE
               num_legs  num_arms
class  name
mammal cat            4         0
       dog            4         0
       monkey         2         2

>>> df.rename_axis(index=str.upper).sort_index()  # doctest: +NORMALIZE_WHITESPACE
               num_legs  num_arms
TYPE   NAME
mammal cat            4         0
       dog            4         0
       monkey         2         2
def rename_axis(self, mapper: Union[(Any, Sequence[Any], Dict[(Name, Any)], Callable[([Name], Any)])]=None, index: Union[(Any, Sequence[Any], Dict[(Name, Any)], Callable[([Name], Any)])]=None, columns: Union[(Any, Sequence[Any], Dict[(Name, Any)], Callable[([Name], Any)])]=None, axis: Optional[Axis]=0, inplace: Optional[bool]=False) -> Optional['DataFrame']:
    '\n        Set the name of the axis for the index or columns.\n\n        Parameters\n        ----------\n        mapper : scalar, list-like, optional\n            A scalar, list-like, dict-like or functions transformations to\n            apply to the axis name attribute.\n        index, columns : scalar, list-like, dict-like or function, optional\n            A scalar, list-like, dict-like or functions transformations to\n            apply to that axis\' values.\n\n            Use either ``mapper`` and ``axis`` to\n            specify the axis to target with ``mapper``, or ``index``\n            and/or ``columns``.\n        axis : {0 or \'index\', 1 or \'columns\'}, default 0\n            The axis to rename.\n        inplace : bool, default False\n            Modifies the object directly, instead of creating a new DataFrame.\n\n        Returns\n        -------\n        DataFrame, or None if `inplace` is True.\n\n        See Also\n        --------\n        Series.rename : Alter Series index labels or name.\n        DataFrame.rename : Alter DataFrame index labels or name.\n        Index.rename : Set new names on index.\n\n        Notes\n        -----\n        ``DataFrame.rename_axis`` supports two calling conventions\n\n        * ``(index=index_mapper, columns=columns_mapper, ...)``\n        * ``(mapper, axis={\'index\', \'columns\'}, ...)``\n\n        The first calling convention will only modify the names of\n        the index and/or the names of the Index object that is the columns.\n\n        The second calling convention will modify the names of the\n        corresponding index specified by axis.\n\n        We *highly* recommend using keyword arguments to clarify your\n        intent.\n\n        Examples\n        --------\n        >>> df = ps.DataFrame({"num_legs": [4, 4, 2],\n        ...                    "num_arms": [0, 0, 2]},\n        ...                   index=["dog", "cat", "monkey"],\n        ...                   columns=["num_legs", "num_arms"])\n        >>> df\n                num_legs  num_arms\n        dog            4         0\n        cat            4         0\n        monkey         2         2\n\n        >>> df = df.rename_axis("animal").sort_index()\n        >>> df  # doctest: +NORMALIZE_WHITESPACE\n                num_legs  num_arms\n        animal\n        cat            4         0\n        dog            4         0\n        monkey         2         2\n\n        >>> df = df.rename_axis("limbs", axis="columns").sort_index()\n        >>> df # doctest: +NORMALIZE_WHITESPACE\n        limbs   num_legs  num_arms\n        animal\n        cat            4         0\n        dog            4         0\n        monkey         2         2\n\n        **MultiIndex**\n\n        >>> index = pd.MultiIndex.from_product([[\'mammal\'],\n        ...                                     [\'dog\', \'cat\', \'monkey\']],\n        ...                                    names=[\'type\', \'name\'])\n        >>> df = ps.DataFrame({"num_legs": [4, 4, 2],\n        ...                    "num_arms": [0, 0, 2]},\n        ...                   index=index,\n        ...                   columns=["num_legs", "num_arms"])\n        >>> df  # doctest: +NORMALIZE_WHITESPACE\n                       num_legs  num_arms\n        type   name\n        mammal dog            4         0\n               cat            4         0\n               monkey         2         2\n\n        >>> df.rename_axis(index={\'type\': \'class\'}).sort_index()  # doctest: +NORMALIZE_WHITESPACE\n                       num_legs  num_arms\n        class  name\n        mammal cat            4         0\n               dog            4         0\n               monkey         2         2\n\n        >>> df.rename_axis(index=str.upper).sort_index()  # doctest: +NORMALIZE_WHITESPACE\n                       num_legs  num_arms\n        TYPE   NAME\n        mammal cat            4         0\n               dog            4         0\n               monkey         2         2\n        '

    def gen_names(v: Union[(Any, Sequence[Any], Dict[(Name, Any)], Callable[([Name], Any)])], curnames: List[Name]) -> List[Label]:
        newnames: List[Name]
        if is_scalar(v):
            newnames = [cast(Name, v)]
        elif (is_list_like(v) and (not is_dict_like(v))):
            newnames = list(cast(Sequence[Name], v))
        elif is_dict_like(v):
            v_dict = cast(Dict[(Name, Name)], v)
            newnames = [(v_dict[name] if (name in v_dict) else name) for name in curnames]
        elif callable(v):
            v_callable = cast(Callable[([Name], Name)], v)
            newnames = [v_callable(name) for name in curnames]
        else:
            raise ValueError('`mapper` or `index` or `columns` should be either dict-like or function type.')
        if (len(newnames) != len(curnames)):
            raise ValueError('Length of new names must be {}, got {}'.format(len(curnames), len(newnames)))
        return [(name if is_name_like_tuple(name) else (name,)) for name in newnames]
    if ((mapper is not None) and ((index is not None) or (columns is not None))):
        raise TypeError("Cannot specify both 'mapper' and any of 'index' or 'columns'.")
    if (mapper is not None):
        axis = validate_axis(axis)
        if (axis == 0):
            index = mapper
        elif (axis == 1):
            columns = mapper
    column_label_names = (gen_names(columns, self.columns.names) if (columns is not None) else self._internal.column_label_names)
    index_names = (gen_names(index, self.index.names) if (index is not None) else self._internal.index_names)
    internal = self._internal.copy(index_names=index_names, column_label_names=column_label_names)
    if inplace:
        self._update_internal_frame(internal)
        return None
    else:
        return DataFrame(internal)