cat.
remove_categories
Remove the specified categories.
removals must be included in the old categories. Values which were in the removed categories will be set to NaN
The categories which should be removed.
Categorical with removed categories or None if inplace=True.
inplace=True
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
>>> s = ps.Series(list("abbccc"), dtype="category") >>> s 0 a 1 b 2 b 3 c 4 c 5 c dtype: category Categories (3, object): ['a', 'b', 'c']
>>> s.cat.remove_categories('b') 0 a 1 NaN 2 NaN 3 c 4 c 5 c dtype: category Categories (2, object): ['a', 'c']