用法:
CategoricalIndex.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.CategoricalIndex.remove_categories用法及代碼示例
- Python pandas.CategoricalIndex.rename_categories用法及代碼示例
- Python pandas.CategoricalIndex.add_categories用法及代碼示例
- Python pandas.CategoricalIndex.map用法及代碼示例
- Python pandas.CategoricalIndex用法及代碼示例
- Python pandas.Categorical用法及代碼示例
- Python pandas.Categorical.from_codes用法及代碼示例
- Python pandas.CategoricalDtype用法及代碼示例
- Python pandas.arrays.IntervalArray.is_empty用法及代碼示例
- Python pandas.DataFrame.ewm用法及代碼示例
- Python pandas.api.types.is_timedelta64_ns_dtype用法及代碼示例
- Python pandas.DataFrame.dot用法及代碼示例
- Python pandas.DataFrame.apply用法及代碼示例
- Python pandas.DataFrame.combine_first用法及代碼示例
- Python pandas.read_pickle用法及代碼示例
- Python pandas.Index.value_counts用法及代碼示例
- Python pandas.DatetimeTZDtype用法及代碼示例
- Python pandas.DataFrame.cumsum用法及代碼示例
- Python pandas.Interval.is_empty用法及代碼示例
- Python pandas.api.indexers.FixedForwardWindowIndexer用法及代碼示例
注:本文由純淨天空篩選整理自pandas.pydata.org大神的英文原創作品 pandas.CategoricalIndex.remove_unused_categories。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。