pyspark.pandas.Series.rename¶
-
Series.
rename
(index: Union[Any, Tuple[Any, …], Callable[[Any], Any], None] = None, **kwargs: Any) → pyspark.pandas.series.Series¶ Alter Series index labels or name.
- Parameters
- indexscalar or function, optional
Functions are transformations to apply to the index. Scalar will alter the Series.name attribute.
- inplacebool, default False
Whether to return a new Series. If True then value of copy is ignored.
- Returns
- Series
Series with index labels or name altered.
Examples
>>> s = ps.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