Table Of Contents

Search

Enter search terms or a module, class or function name.

pandas.Series.cat.rename_categories

Series.cat.rename_categories(*args, **kwargs)[source]

Renames categories.

The new categories can be either a list-like dict-like object. If it is list-like, all items must be unique and the number of items in the new categories must be the same as the number of items in the old categories.

Parameters:

new_categories : Index-like or dict-like (>=0.21.0)

The renamed categories.

inplace : boolean (default: False)

Whether or not to rename the categories inplace or return a copy of this categorical with renamed categories.

Returns:

cat : Categorical with renamed categories added or None if inplace.

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

Scroll To Top