# dask.dataframe.Series.cat.reorder_categories

#### dataframe.Series.cat.reorder_categories(new_categories, ordered=None) → Self

Reorder categories as specified in new_categories.

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

Some inconsistencies with the Dask version may exist.

`new_categories` need to include all old categories and no new category
items.

* **Parameters:**
  **new_categories**
  : The categories in new order.

  **ordered**
  : Whether or not the categorical is treated as an ordered categorical.
    If not given, do not change the ordered information.
* **Returns:**
  Categorical
  : Categorical with reordered categories.
* **Raises:**
  ValueError
  : If the new categories do not contain all old category items or any
    new ones

#### SEE ALSO
[`rename_categories`](dask.dataframe.Series.cat.rename_categories.html.md#dask.dataframe.Series.cat.rename_categories)
: Rename 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.

### Examples

For [`pandas.Series`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.Series.html#pandas.Series):

```pycon
>>> ser = pd.Series(["a", "b", "c", "a"], dtype="category")
>>> ser = ser.cat.reorder_categories(["c", "b", "a"], ordered=True)
>>> ser
0   a
1   b
2   c
3   a
dtype: category
Categories (3, str): ['c' < 'b' < 'a']
```

```pycon
>>> ser.sort_values()
2   c
1   b
0   a
3   a
dtype: category
Categories (3, str): ['c' < 'b' < 'a']
```

For [`pandas.CategoricalIndex`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.CategoricalIndex.html#pandas.CategoricalIndex):

```pycon
>>> ci = pd.CategoricalIndex(["a", "b", "c", "a"])
>>> ci
CategoricalIndex(['a', 'b', 'c', 'a'], categories=['a', 'b', 'c'],
                 ordered=False, dtype='category')
>>> ci.reorder_categories(["c", "b", "a"], ordered=True)
CategoricalIndex(['a', 'b', 'c', 'a'], categories=['c', 'b', 'a'],
                 ordered=True, dtype='category')
```

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