You are viewing documentation about an older version (1.18.0). View latest version

modin.pandas.Series.rename¶

Series.rename(index: Renamer | Hashable | None = None, *, axis: Axis | None = None, copy: bool | None = None, inplace: bool = False, level: Level | None = None, errors: IgnoreRaise = 'ignore') → Series | None[source]¶

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.

Parameters:
  • index (scalar, hashable sequence, dict-like or function optional) – Functions or dict-like are transformations to apply to the index. Scalar or hashable sequence-like will alter the Series.name attribute.

  • axis ({0 or 'index'}) – Unused. Parameter needed for compatibility with DataFrame.

  • copy (bool, default True) – Also copy underlying data. copy has been ignored with Snowflake execution engine.

  • inplace (bool, default False) – Whether to return a new Series. If True the value of copy is ignored.

  • level (int or level name, default None) – In case of MultiIndex, only rename labels in the specified level.

  • errors ({'ignore', 'raise'}, default 'ignore') – If ‘raise’, raise KeyError when a dict-like mapper or index 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:

Series with index labels or name altered or None if inplace=True.

Return type:

Series or None

See also

DataFrame.rename

Corresponding DataFrame method.

Series.rename_axis

Set the name of the axis.

Examples

>>> s = pd.Series([1, 2, 3])
>>> s
0    1
1    2
2    3
dtype: int64
>>> s.rename("my_name")  # scalar, changes Series.name
0    1
1    2
2    3
Name: my_name, dtype: int64
>>> s.rename({1: 3, 2: 5})  # mapping, changes labels
0    1
3    2
5    3
dtype: int64
Copy