dask.dataframe.Series.cat.remove_categories

dask.dataframe.Series.cat.remove_categories

dataframe.Series.cat.remove_categories(*args, **kwargs)

Remove the specified categories.

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

Some inconsistencies with the Dask version may exist.

removals must be included in the old categories. Values which were in the removed categories will be set to NaN

Parameters
removalscategory or list of categories

The categories which should be removed.

Returns
Categorical

Categorical with removed categories.

Raises
ValueError

If the removals are not contained in the categories

See also

rename_categories

Rename categories.

reorder_categories

Reorder categories.

add_categories

Add new categories.

remove_unused_categories

Remove categories which are not used.

set_categories

Set the categories to the specified ones.

Examples

>>> c = pd.Categorical(['a', 'c', 'b', 'c', 'd'])  
>>> c  
['a', 'c', 'b', 'c', 'd']
Categories (4, object): ['a', 'b', 'c', 'd']
>>> c.remove_categories(['d', 'a'])  
[NaN, 'c', 'b', 'c', NaN]
Categories (2, object): ['b', 'c']