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.
Functions or dict-like are transformations to apply to the index. Scalar or hashable sequence-like will alter the Series.name
attribute.
Unused. Parameter needed for compatibility with DataFrame.
Also copy underlying data.
Note
The copy keyword will change behavior in pandas 3.0. Copy-on-Write will be enabled by default, which means that all methods with a copy keyword will use a lazy copy mechanism to defer the copy and ignore the copy keyword. The copy keyword will be removed in a future version of pandas.
You can already get the future behavior and improvements through enabling copy on write pd.options.mode.copy_on_write = True
Whether to return a new Series. If True the value of copy is ignored.
In case of MultiIndex, only rename labels in the specified level.
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.
Series with index labels or name altered or None if inplace=True
.
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(lambda x: x ** 2) # function, changes labels 0 1 1 2 4 3 dtype: int64 >>> s.rename({1: 3, 2: 5}) # mapping, changes labels 0 1 3 2 5 3 dtype: int64
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4