用法:
CategoricalIndex.add_categories(*args, **kwargs)
添加新類別。
new_categories
將包含在類別中的最後/最高位置,並且在此調用後將直接不使用。- new_categories:類別或類別的list-like
要包含的新類別。
- inplace:布爾值,默認為 False
是否就地添加類別或返回此類別的副本以及添加的類別。
- cat:分類或無
添加了新類別的分類,如果
inplace=True
則為無。
- ValueError
如果新類別包括舊類別或不作為類別驗證
參數:
返回:
拋出:
例子:
>>> c = pd.Categorical(['c', 'b', 'c']) >>> c ['c', 'b', 'c'] Categories (2, object):['b', 'c']
>>> c.add_categories(['d', 'a']) ['c', 'b', 'c'] Categories (4, object):['b', 'c', 'd', 'a']
相關用法
- Python pandas.CategoricalIndex.remove_unused_categories用法及代碼示例
- Python pandas.CategoricalIndex.remove_categories用法及代碼示例
- Python pandas.CategoricalIndex.map用法及代碼示例
- Python pandas.CategoricalIndex.rename_categories用法及代碼示例
- 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.add_categories。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。