pandas.Series.cat.remove_unused_categories
pandas 3.1.1 · Series and accessors · method
Remove declared categories that do not occur in the data.
Call syntax
Series.cat.remove_unused_categories()Run the example
Edit the example and select Run Python to see the result.
Parameters
This call takes no arguments.
Returns
Categorical