用法:
Series.cat.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.Series.cat.remove_categories用法及代碼示例
- Python pandas.Series.cat.rename_categories用法及代碼示例
- Python pandas.Series.cat.remove_unused_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.add_categories。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。