def rename(self, mapper: Optional[Union[(Dict, Callable[([Any], Any)])]]=None, index: Optional[Union[(Dict, Callable[([Any], Any)])]]=None, columns: Optional[Union[(Dict, Callable[([Any], Any)])]]=None, axis: Axis='index', inplace: bool=False, level: Optional[int]=None, errors: str='ignore') -> Optional['DataFrame']:
    '\n        Alter axes labels.\n        Function / dict values must be unique (1-to-1). Labels not contained in a dict / Series\n        will be left as-is. Extra labels listed don’t throw an error.\n\n        Parameters\n        ----------\n        mapper : dict-like or function\n            Dict-like or functions transformations to apply to that axis’ values.\n            Use either `mapper` and `axis` to specify the axis to target with `mapper`, or `index`\n            and `columns`.\n        index : dict-like or function\n            Alternative to specifying axis ("mapper, axis=0" is equivalent to "index=mapper").\n        columns : dict-like or function\n            Alternative to specifying axis ("mapper, axis=1" is equivalent to "columns=mapper").\n        axis : int or str, default \'index\'\n            Axis to target with mapper. Can be either the axis name (\'index\', \'columns\') or\n            number (0, 1).\n        inplace : bool, default False\n            Whether to return a new DataFrame.\n        level : int or level name, default None\n            In case of a MultiIndex, only rename labels in the specified level.\n        errors : {\'ignore\', \'raise}, default \'ignore\'\n            If \'raise\', raise a `KeyError` when a dict-like `mapper`, `index`, or `columns`\n            contains labels that are not present in the Index being transformed. If \'ignore\',\n            existing keys will be renamed and extra keys will be ignored.\n\n        Returns\n        -------\n        DataFrame with the renamed axis labels.\n\n        Raises\n        ------\n        `KeyError`\n            If any of the labels is not found in the selected axis and "errors=\'raise\'".\n\n        Examples\n        --------\n        >>> psdf1 = ps.DataFrame({"A": [1, 2, 3], "B": [4, 5, 6]})\n        >>> psdf1.rename(columns={"A": "a", "B": "c"})  # doctest: +NORMALIZE_WHITESPACE\n           a  c\n        0  1  4\n        1  2  5\n        2  3  6\n\n        >>> psdf1.rename(index={1: 10, 2: 20})  # doctest: +NORMALIZE_WHITESPACE\n            A  B\n        0   1  4\n        10  2  5\n        20  3  6\n\n        >>> def str_lower(s) -> str:\n        ...     return str.lower(s)\n        >>> psdf1.rename(str_lower, axis=\'columns\')  # doctest: +NORMALIZE_WHITESPACE\n           a  b\n        0  1  4\n        1  2  5\n        2  3  6\n\n        >>> def mul10(x) -> int:\n        ...     return x * 10\n        >>> psdf1.rename(mul10, axis=\'index\')  # doctest: +NORMALIZE_WHITESPACE\n            A  B\n        0   1  4\n        10  2  5\n        20  3  6\n\n        >>> idx = pd.MultiIndex.from_tuples([(\'X\', \'A\'), (\'X\', \'B\'), (\'Y\', \'C\'), (\'Y\', \'D\')])\n        >>> psdf2 = ps.DataFrame([[1, 2, 3, 4], [5, 6, 7, 8]], columns=idx)\n        >>> psdf2.rename(columns=str_lower, level=0)  # doctest: +NORMALIZE_WHITESPACE\n           x     y\n           A  B  C  D\n        0  1  2  3  4\n        1  5  6  7  8\n\n        >>> psdf3 = ps.DataFrame([[1, 2], [3, 4], [5, 6], [7, 8]], index=idx, columns=list(\'ab\'))\n        >>> psdf3.rename(index=str_lower)  # doctest: +NORMALIZE_WHITESPACE\n             a  b\n        x a  1  2\n          b  3  4\n        y c  5  6\n          d  7  8\n        '

    def gen_mapper_fn(mapper: Union[(Dict, Callable[([Any], Any)])]) -> Tuple[(Callable[([Any], Any)], Dtype, DataType)]:
        if isinstance(mapper, dict):
            mapper_dict = mapper
            type_set = set(map((lambda x: type(x)), mapper_dict.values()))
            if (len(type_set) > 1):
                raise ValueError('Mapper dict should have the same value type.')
            (dtype, spark_return_type) = pandas_on_spark_type(list(type_set)[0])

            def mapper_fn(x: Any) -> Any:
                if (x in mapper_dict):
                    return mapper_dict[x]
                else:
                    if (errors == 'raise'):
                        raise KeyError('Index include value which is not in the `mapper`')
                    return x
        elif callable(mapper):
            mapper_callable = cast(Callable, mapper)
            return_type = cast(ScalarType, infer_return_type(mapper))
            dtype = return_type.dtype
            spark_return_type = return_type.spark_type

            def mapper_fn(x: Any) -> Any:
                return mapper_callable(x)
        else:
            raise ValueError('`mapper` or `index` or `columns` should be either dict-like or function type.')
        return (mapper_fn, dtype, spark_return_type)
    index_mapper_fn = None
    index_mapper_ret_stype = None
    columns_mapper_fn = None
    inplace = validate_bool_kwarg(inplace, 'inplace')
    if mapper:
        axis = validate_axis(axis)
        if (axis == 0):
            (index_mapper_fn, index_mapper_ret_dtype, index_mapper_ret_stype) = gen_mapper_fn(mapper)
        elif (axis == 1):
            (columns_mapper_fn, _, _) = gen_mapper_fn(mapper)
    else:
        if index:
            (index_mapper_fn, index_mapper_ret_dtype, index_mapper_ret_stype) = gen_mapper_fn(index)
        if columns:
            (columns_mapper_fn, _, _) = gen_mapper_fn(columns)
        if ((not index) and (not columns)):
            raise ValueError('Either `index` or `columns` should be provided.')
    psdf = self.copy()
    if index_mapper_fn:
        index_columns = psdf._internal.index_spark_column_names
        num_indices = len(index_columns)
        if level:
            if ((level < 0) or (level >= num_indices)):
                raise ValueError('level should be an integer between [0, num_indices)')

        @pandas_udf(returnType=index_mapper_ret_stype)
        def index_mapper_udf(s: pd.Series) -> pd.Series:
            return s.map(index_mapper_fn)
        index_spark_columns = psdf._internal.index_spark_columns.copy()
        index_fields = psdf._internal.index_fields.copy()
        if (level is None):
            for i in range(num_indices):
                index_spark_columns[i] = index_mapper_udf(index_spark_columns[i]).alias(index_columns[i])
                index_fields[i] = index_fields[i].copy(dtype=index_mapper_ret_dtype, spark_type=index_mapper_ret_stype, nullable=True)
        else:
            index_spark_columns[level] = index_mapper_udf(index_spark_columns[level]).alias(index_columns[level])
            index_fields[level] = index_fields[level].copy(dtype=index_mapper_ret_dtype, spark_type=index_mapper_ret_stype, nullable=True)
        psdf = DataFrame(psdf._internal.copy(index_spark_columns=index_spark_columns, index_fields=index_fields))
    if columns_mapper_fn:
        if level:
            if ((level < 0) or (level >= psdf._internal.column_labels_level)):
                raise ValueError('level should be an integer between [0, column_labels_level)')

        def gen_new_column_labels_entry(column_labels_entry: Label) -> Label:
            if (level is None):
                return tuple(map(columns_mapper_fn, column_labels_entry))
            else:
                entry_list = list(column_labels_entry)
                entry_list[level] = columns_mapper_fn(entry_list[level])
                return tuple(entry_list)
        new_column_labels = list(map(gen_new_column_labels_entry, psdf._internal.column_labels))
        new_data_pssers = [psdf._psser_for(old_label).rename(new_label) for (old_label, new_label) in zip(psdf._internal.column_labels, new_column_labels)]
        psdf = DataFrame(psdf._internal.with_new_columns(new_data_pssers))
    if inplace:
        self._update_internal_frame(psdf._internal)
        return None
    else:
        return psdf
Alter axes labels.
Function / dict values must be unique (1-to-1). Labels not contained in a dict / Series
will be left as-is. Extra labels listed don’t throw an error.

Parameters
----------
mapper : dict-like or function
    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 `columns`.
index : dict-like or function
    Alternative to specifying axis ("mapper, axis=0" is equivalent to "index=mapper").
columns : dict-like or function
    Alternative to specifying axis ("mapper, axis=1" is equivalent to "columns=mapper").
axis : int or str, default 'index'
    Axis to target with mapper. Can be either the axis name ('index', 'columns') or
    number (0, 1).
inplace : bool, default False
    Whether to return a new DataFrame.
level : int or level name, default None
    In case of a MultiIndex, only rename labels in the specified level.
errors : {'ignore', 'raise}, default 'ignore'
    If 'raise', raise a `KeyError` when a dict-like `mapper`, `index`, or `columns`
    contains labels that are not present in the Index being transformed. If 'ignore',
    existing keys will be renamed and extra keys will be ignored.

Returns
-------
DataFrame with the renamed axis labels.

Raises
------
`KeyError`
    If any of the labels is not found in the selected axis and "errors='raise'".

Examples
--------
>>> psdf1 = ps.DataFrame({"A": [1, 2, 3], "B": [4, 5, 6]})
>>> psdf1.rename(columns={"A": "a", "B": "c"})  # doctest: +NORMALIZE_WHITESPACE
   a  c
0  1  4
1  2  5
2  3  6

>>> psdf1.rename(index={1: 10, 2: 20})  # doctest: +NORMALIZE_WHITESPACE
    A  B
0   1  4
10  2  5
20  3  6

>>> def str_lower(s) -> str:
...     return str.lower(s)
>>> psdf1.rename(str_lower, axis='columns')  # doctest: +NORMALIZE_WHITESPACE
   a  b
0  1  4
1  2  5
2  3  6

>>> def mul10(x) -> int:
...     return x * 10
>>> psdf1.rename(mul10, axis='index')  # doctest: +NORMALIZE_WHITESPACE
    A  B
0   1  4
10  2  5
20  3  6

>>> idx = pd.MultiIndex.from_tuples([('X', 'A'), ('X', 'B'), ('Y', 'C'), ('Y', 'D')])
>>> psdf2 = ps.DataFrame([[1, 2, 3, 4], [5, 6, 7, 8]], columns=idx)
>>> psdf2.rename(columns=str_lower, level=0)  # doctest: +NORMALIZE_WHITESPACE
   x     y
   A  B  C  D
0  1  2  3  4
1  5  6  7  8

>>> psdf3 = ps.DataFrame([[1, 2], [3, 4], [5, 6], [7, 8]], index=idx, columns=list('ab'))
>>> psdf3.rename(index=str_lower)  # doctest: +NORMALIZE_WHITESPACE
     a  b
x a  1  2
  b  3  4
y c  5  6
  d  7  8
def rename(self, mapper: Optional[Union[(Dict, Callable[([Any], Any)])]]=None, index: Optional[Union[(Dict, Callable[([Any], Any)])]]=None, columns: Optional[Union[(Dict, Callable[([Any], Any)])]]=None, axis: Axis='index', inplace: bool=False, level: Optional[int]=None, errors: str='ignore') -> Optional['DataFrame']:
    '\n        Alter axes labels.\n        Function / dict values must be unique (1-to-1). Labels not contained in a dict / Series\n        will be left as-is. Extra labels listed don’t throw an error.\n\n        Parameters\n        ----------\n        mapper : dict-like or function\n            Dict-like or functions transformations to apply to that axis’ values.\n            Use either `mapper` and `axis` to specify the axis to target with `mapper`, or `index`\n            and `columns`.\n        index : dict-like or function\n            Alternative to specifying axis ("mapper, axis=0" is equivalent to "index=mapper").\n        columns : dict-like or function\n            Alternative to specifying axis ("mapper, axis=1" is equivalent to "columns=mapper").\n        axis : int or str, default \'index\'\n            Axis to target with mapper. Can be either the axis name (\'index\', \'columns\') or\n            number (0, 1).\n        inplace : bool, default False\n            Whether to return a new DataFrame.\n        level : int or level name, default None\n            In case of a MultiIndex, only rename labels in the specified level.\n        errors : {\'ignore\', \'raise}, default \'ignore\'\n            If \'raise\', raise a `KeyError` when a dict-like `mapper`, `index`, or `columns`\n            contains labels that are not present in the Index being transformed. If \'ignore\',\n            existing keys will be renamed and extra keys will be ignored.\n\n        Returns\n        -------\n        DataFrame with the renamed axis labels.\n\n        Raises\n        ------\n        `KeyError`\n            If any of the labels is not found in the selected axis and "errors=\'raise\'".\n\n        Examples\n        --------\n        >>> psdf1 = ps.DataFrame({"A": [1, 2, 3], "B": [4, 5, 6]})\n        >>> psdf1.rename(columns={"A": "a", "B": "c"})  # doctest: +NORMALIZE_WHITESPACE\n           a  c\n        0  1  4\n        1  2  5\n        2  3  6\n\n        >>> psdf1.rename(index={1: 10, 2: 20})  # doctest: +NORMALIZE_WHITESPACE\n            A  B\n        0   1  4\n        10  2  5\n        20  3  6\n\n        >>> def str_lower(s) -> str:\n        ...     return str.lower(s)\n        >>> psdf1.rename(str_lower, axis=\'columns\')  # doctest: +NORMALIZE_WHITESPACE\n           a  b\n        0  1  4\n        1  2  5\n        2  3  6\n\n        >>> def mul10(x) -> int:\n        ...     return x * 10\n        >>> psdf1.rename(mul10, axis=\'index\')  # doctest: +NORMALIZE_WHITESPACE\n            A  B\n        0   1  4\n        10  2  5\n        20  3  6\n\n        >>> idx = pd.MultiIndex.from_tuples([(\'X\', \'A\'), (\'X\', \'B\'), (\'Y\', \'C\'), (\'Y\', \'D\')])\n        >>> psdf2 = ps.DataFrame([[1, 2, 3, 4], [5, 6, 7, 8]], columns=idx)\n        >>> psdf2.rename(columns=str_lower, level=0)  # doctest: +NORMALIZE_WHITESPACE\n           x     y\n           A  B  C  D\n        0  1  2  3  4\n        1  5  6  7  8\n\n        >>> psdf3 = ps.DataFrame([[1, 2], [3, 4], [5, 6], [7, 8]], index=idx, columns=list(\'ab\'))\n        >>> psdf3.rename(index=str_lower)  # doctest: +NORMALIZE_WHITESPACE\n             a  b\n        x a  1  2\n          b  3  4\n        y c  5  6\n          d  7  8\n        '

    def gen_mapper_fn(mapper: Union[(Dict, Callable[([Any], Any)])]) -> Tuple[(Callable[([Any], Any)], Dtype, DataType)]:
        if isinstance(mapper, dict):
            mapper_dict = mapper
            type_set = set(map((lambda x: type(x)), mapper_dict.values()))
            if (len(type_set) > 1):
                raise ValueError('Mapper dict should have the same value type.')
            (dtype, spark_return_type) = pandas_on_spark_type(list(type_set)[0])

            def mapper_fn(x: Any) -> Any:
                if (x in mapper_dict):
                    return mapper_dict[x]
                else:
                    if (errors == 'raise'):
                        raise KeyError('Index include value which is not in the `mapper`')
                    return x
        elif callable(mapper):
            mapper_callable = cast(Callable, mapper)
            return_type = cast(ScalarType, infer_return_type(mapper))
            dtype = return_type.dtype
            spark_return_type = return_type.spark_type

            def mapper_fn(x: Any) -> Any:
                return mapper_callable(x)
        else:
            raise ValueError('`mapper` or `index` or `columns` should be either dict-like or function type.')
        return (mapper_fn, dtype, spark_return_type)
    index_mapper_fn = None
    index_mapper_ret_stype = None
    columns_mapper_fn = None
    inplace = validate_bool_kwarg(inplace, 'inplace')
    if mapper:
        axis = validate_axis(axis)
        if (axis == 0):
            (index_mapper_fn, index_mapper_ret_dtype, index_mapper_ret_stype) = gen_mapper_fn(mapper)
        elif (axis == 1):
            (columns_mapper_fn, _, _) = gen_mapper_fn(mapper)
    else:
        if index:
            (index_mapper_fn, index_mapper_ret_dtype, index_mapper_ret_stype) = gen_mapper_fn(index)
        if columns:
            (columns_mapper_fn, _, _) = gen_mapper_fn(columns)
        if ((not index) and (not columns)):
            raise ValueError('Either `index` or `columns` should be provided.')
    psdf = self.copy()
    if index_mapper_fn:
        index_columns = psdf._internal.index_spark_column_names
        num_indices = len(index_columns)
        if level:
            if ((level < 0) or (level >= num_indices)):
                raise ValueError('level should be an integer between [0, num_indices)')

        @pandas_udf(returnType=index_mapper_ret_stype)
        def index_mapper_udf(s: pd.Series) -> pd.Series:
            return s.map(index_mapper_fn)
        index_spark_columns = psdf._internal.index_spark_columns.copy()
        index_fields = psdf._internal.index_fields.copy()
        if (level is None):
            for i in range(num_indices):
                index_spark_columns[i] = index_mapper_udf(index_spark_columns[i]).alias(index_columns[i])
                index_fields[i] = index_fields[i].copy(dtype=index_mapper_ret_dtype, spark_type=index_mapper_ret_stype, nullable=True)
        else:
            index_spark_columns[level] = index_mapper_udf(index_spark_columns[level]).alias(index_columns[level])
            index_fields[level] = index_fields[level].copy(dtype=index_mapper_ret_dtype, spark_type=index_mapper_ret_stype, nullable=True)
        psdf = DataFrame(psdf._internal.copy(index_spark_columns=index_spark_columns, index_fields=index_fields))
    if columns_mapper_fn:
        if level:
            if ((level < 0) or (level >= psdf._internal.column_labels_level)):
                raise ValueError('level should be an integer between [0, column_labels_level)')

        def gen_new_column_labels_entry(column_labels_entry: Label) -> Label:
            if (level is None):
                return tuple(map(columns_mapper_fn, column_labels_entry))
            else:
                entry_list = list(column_labels_entry)
                entry_list[level] = columns_mapper_fn(entry_list[level])
                return tuple(entry_list)
        new_column_labels = list(map(gen_new_column_labels_entry, psdf._internal.column_labels))
        new_data_pssers = [psdf._psser_for(old_label).rename(new_label) for (old_label, new_label) in zip(psdf._internal.column_labels, new_column_labels)]
        psdf = DataFrame(psdf._internal.with_new_columns(new_data_pssers))
    if inplace:
        self._update_internal_frame(psdf._internal)
        return None
    else:
        return psdf