# dask.dataframe.Series.cat.rename_categories

#### dataframe.Series.cat.rename_categories(new_categories) → Self

Rename categories.

This docstring was copied from pandas.core.arrays.categorical.CategoricalAccessor.rename_categories.

Some inconsistencies with the Dask version may exist.

This method is commonly used to re-label or adjust the
category names in categorical data without changing the
underlying data. It is useful in situations where you want
to modify the labels used for clarity, consistency,
or readability.

* **Parameters:**
  **new_categories**
  : New categories which will replace old categories.
    * list-like: all items must be unique and the number of items in
      the new categories must match the existing number of categories.
    * dict-like: specifies a mapping from
      old categories to new. Categories not contained in the mapping
      are passed through and extra categories in the mapping are
      ignored.
    * callable : a callable that is called on all items in the old
      categories and whose return values comprise the new categories.
* **Returns:**
  Categorical
  : Categorical with renamed categories.
* **Raises:**
  ValueError
  : If new categories are list-like and do not have the same number of
    items than the current categories or do not validate as categories

#### SEE ALSO
[`reorder_categories`](dask.dataframe.Series.cat.reorder_categories.html.md#dask.dataframe.Series.cat.reorder_categories)
: Reorder categories.

[`add_categories`](dask.dataframe.Series.cat.add_categories.html.md#dask.dataframe.Series.cat.add_categories)
: Add new categories.

[`remove_categories`](dask.dataframe.Series.cat.remove_categories.html.md#dask.dataframe.Series.cat.remove_categories)
: Remove the specified categories.

[`remove_unused_categories`](dask.dataframe.Series.cat.remove_unused_categories.html.md#dask.dataframe.Series.cat.remove_unused_categories)
: Remove categories which are not used.

[`set_categories`](dask.dataframe.Series.cat.set_categories.html.md#dask.dataframe.Series.cat.set_categories)
: Set the categories to the specified ones.

`Series.replace`
: Replace values, e.g. to merge several categories into one.

### Examples

```pycon
>>> c = pd.Categorical(["a", "a", "b"])
>>> c.rename_categories([0, 1])
[0, 0, 1]
Categories (2, int64): [0, 1]
```

For dict-like `new_categories`, extra keys are ignored and
categories not in the dictionary are passed through

```pycon
>>> c.rename_categories({"a": "A", "c": "C"})
['A', 'A', 'b']
Categories (2, str): ['A', 'b']
```

You may also provide a callable to create the new categories

```pycon
>>> c.rename_categories(lambda x: x.upper())
['A', 'A', 'B']
Categories (2, str): ['A', 'B']
```

<!-- !! processed by numpydoc !! -->
