用法:
Series.cat.remove_unused_categories(*args, **kwargs)
刪除不使用的類別。
- inplace:布爾值,默認為 False
是否刪除未使用的類別或返回此分類的副本,其中未使用的類別已刪除。
- cat:分類或無
如果
inplace=True
,則刪除未使用的類別或 None 。
參數:
返回:
例子:
>>> c = pd.Categorical(['a', 'c', 'b', 'c', 'd']) >>> c ['a', 'c', 'b', 'c', 'd'] Categories (4, object):['a', 'b', 'c', 'd']
>>> c[2] = 'a' >>> c[4] = 'c' >>> c ['a', 'c', 'a', 'c', 'c'] Categories (4, object):['a', 'b', 'c', 'd']
>>> c.remove_unused_categories() ['a', 'c', 'a', 'c', 'c'] Categories (2, object):['a', 'c']
相關用法
- Python pandas.Series.cat.remove_categories用法及代碼示例
- Python pandas.Series.cat.rename_categories用法及代碼示例
- Python pandas.Series.cat.add_categories用法及代碼示例
- Python pandas.Series.cat用法及代碼示例
- Python pandas.Series.combine_first用法及代碼示例
- Python pandas.Series.convert_dtypes用法及代碼示例
- Python pandas.Series.combine用法及代碼示例
- Python pandas.Series.compare用法及代碼示例
- Python pandas.Series.copy用法及代碼示例
- Python pandas.Series.cumsum用法及代碼示例
- Python pandas.Series.cumprod用法及代碼示例
- Python pandas.Series.cov用法及代碼示例
- Python pandas.Series.cummin用法及代碼示例
- Python pandas.Series.cummax用法及代碼示例
- Python pandas.Series.count用法及代碼示例
- Python pandas.Series.clip用法及代碼示例
- Python pandas.Series.corr用法及代碼示例
- Python pandas.Series.add_prefix用法及代碼示例
- Python pandas.Series.map用法及代碼示例
- Python pandas.Series.max用法及代碼示例
注:本文由純淨天空篩選整理自pandas.pydata.org大神的英文原創作品 pandas.Series.cat.remove_unused_categories。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。