用法:
CategoricalAccessor.add_categories(new_categories: Any, inplace: bool = False) → Optional[SeriesOrIndex]
添加新類別。
new_categories
將包含在類別中的最後/最高位置,並且在此調用後將直接不使用。- new_categories:類別或類別的list-like
要包含的新類別。
- inplace:布爾值,默認為 False
是否就地添加類別或返回此類別的副本以及添加的類別。
- cat
添加了新類別的分類,如果就地,則為無。
參數:
返回:
例子:
>>> import cudf >>> s = cudf.Series([1, 2], dtype="category") >>> s 0 1 1 2 dtype: category Categories (2, int64): [1, 2] >>> s.cat.add_categories([0, 3, 4]) 0 1 1 2 dtype: category Categories (5, int64): [1, 2, 0, 3, 4] >>> s 0 1 1 2 dtype: category Categories (2, int64): [1, 2] >>> s.cat.add_categories([0, 3, 4], inplace=True) >>> s 0 1 1 2 dtype: category Categories (5, int64): [1, 2, 0, 3, 4]
相關用法
- Python cudf.core.column.categorical.CategoricalAccessor.as_unordered用法及代碼示例
- Python cudf.core.column.categorical.CategoricalAccessor.as_ordered用法及代碼示例
- Python cudf.core.column.categorical.CategoricalAccessor.reorder_categories用法及代碼示例
- Python cudf.core.column.categorical.CategoricalAccessor.remove_categories用法及代碼示例
- Python cudf.core.column.categorical.CategoricalAccessor.set_categories用法及代碼示例
- Python cudf.core.column.string.StringMethods.is_vowel用法及代碼示例
- Python cudf.core.column.string.StringMethods.endswith用法及代碼示例
- Python cudf.core.column.string.StringMethods.title用法及代碼示例
- Python cudf.core.column.string.StringMethods.contains用法及代碼示例
- Python cudf.core.column.string.StringMethods.rsplit用法及代碼示例
- Python cudf.core.column.string.StringMethods.zfill用法及代碼示例
- Python cudf.core.column.string.StringMethods.hex_to_int用法及代碼示例
- Python cudf.core.column.string.StringMethods.htoi用法及代碼示例
- Python cudf.core.column.string.StringMethods.character_tokenize用法及代碼示例
- Python cudf.core.column.string.StringMethods.normalize_characters用法及代碼示例
- Python cudf.core.column.string.StringMethods.filter_alphanum用法及代碼示例
- Python cudf.core.column.string.StringMethods.split用法及代碼示例
- Python cudf.core.column.string.StringMethods.ngrams用法及代碼示例
- Python cudf.core.column.struct.StructMethods.explode用法及代碼示例
- Python cudf.core.column.lists.ListMethods.concat用法及代碼示例
注:本文由純淨天空篩選整理自rapids.ai大神的英文原創作品 cudf.core.column.categorical.CategoricalAccessor.add_categories。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。