remove_unused_categories

hhpy.ds.remove_unused_categories(df: pandas.core.frame.DataFrame, inplace: bool = False) → Optional[pandas.core.frame.DataFrame][source]

Remove unused categories from all categorical columns in the DataFrame

Parameters:
  • df – Pandas DataFrame containing the data, other objects are implicitly cast to DataFrame
  • inplace – Whether to modify the DataFrame inplace [optional]
Returns:

pandas DataFrame with the unused categories removed