pandas.Series.rename

Alter Series index labels or name.

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.

Alternatively, change Series.name with a scalar value.

See the user guide for more.

param index
scalar, hashable sequence, dict-like or function, optional

dict-like or functions are transformations to apply to the index. Scalar or hashable sequence-like will alter the Series.name attribute.

param copy
bool, default True

Whether to copy underlying data.

param inplace
bool, default False

Whether to return a new Series. If True then value of copy is ignored.

param level
int or level name, default None

In case of a MultiIndex, only rename labels in the specified level.

return

Series Series with index labels or name altered.

Limitations

  • Parameter level is currently unsupported by Intel Scalable Dataframe Compiler

Examples

Alter Series index labels or name.
import numpy as np
import pandas as pd
from numba import njit


@njit
def series_rename():
    s = pd.Series(np.arange(5))
    s.rename("new_series")

    return s


print(series_rename())
$ python ./series/series_rename.py
0    0
1    1
2    2
3    3
4    4
dtype: int64