Skip to main content
`Ctrl`+`K`

# pandas.Series.rename_axis

Series.rename_axis(mapper=<no_default>, *, index=<no_default>, axis=0, copy=<no_default>, inplace=False)

  Set the name of the axis for the index.

  This method sets or changes the name of the index (axis) of the Series. It can accept a scalar, list-like, or function to rename the axis.

  Parameters:
    mapper scalar, list-like, optional

      Value to set the axis name attribute.

      Use either `mapper` and `axis` to specify the axis to target with `mapper`, or `index`.

    index scalar, list-like, dict-like or function, optional

      A scalar, list-like, dict-like or functions transformations to apply to that axis’ values.

    axis{0 or ‘index’}, default 0

      The axis to rename. For Series this parameter is unused and defaults to 0.

    copy bool, default False

      This keyword is now ignored; changing its value will have no impact on the method.

      Deprecated since version 3.0.0: This keyword is ignored and will be removed in pandas 4.0. Since pandas 3.0, this method always returns a new object using a lazy copy mechanism that defers copies until necessary (Copy-on-Write). See the user guide on Copy-on-Write for more details.

    inplace bool, default False

      Modifies the object directly, instead of creating a new Series or DataFrame.

  Returns:
    Series, or None

      The same type as the caller or None if `inplace=True`.

  See also

  `Series.rename`

    Alter Series index labels or name.

  `DataFrame.rename`

    Alter DataFrame index labels or name.

  `Index.rename`

    Set new names on index.

  Examples

      >>> s = pd.Series(["dog", "cat", "monkey"])
      >>> s
      0       dog
      1       cat
      2    monkey
      dtype: str
      >>> s.rename_axis("animal")
      animal
      0    dog
      1    cat
      2    monkey
      dtype: str