用法:
classmethod Series.from_categorical(categorical, codes=None)
從 pandas.Categorical 創建
- categorical:pandas.Categorical
包含存儲在 pandas 分類中的數據。
- codes:array-like,可選。
此分類的分類代碼。如果定義了
codes
,則使用它們而不是categorical.codes
- Series
一個 cudf 分類係列。
參數:
返回:
例子:
>>> import cudf >>> import pandas as pd >>> pd_categorical = pd.Categorical(pd.Series(['a', 'b', 'c', 'a'], dtype='category')) >>> pd_categorical ['a', 'b', 'c', 'a'] Categories (3, object): ['a', 'b', 'c'] >>> series = cudf.Series.from_categorical(pd_categorical) >>> series 0 a 1 b 2 c 3 a dtype: category Categories (3, object): ['a', 'b', 'c']
相關用法
- Python cudf.Series.from_pandas用法及代碼示例
- Python cudf.Series.from_masked_array用法及代碼示例
- Python cudf.Series.from_arrow用法及代碼示例
- Python cudf.Series.floordiv用法及代碼示例
- Python cudf.Series.fillna用法及代碼示例
- Python cudf.Series.factorize用法及代碼示例
- Python cudf.Series.first用法及代碼示例
- Python cudf.Series.floor用法及代碼示例
- Python cudf.Series.ceil用法及代碼示例
- Python cudf.Series.update用法及代碼示例
- Python cudf.Series.max用法及代碼示例
- Python cudf.Series.head用法及代碼示例
- Python cudf.Series.reindex用法及代碼示例
- Python cudf.Series.interleave_columns用法及代碼示例
- Python cudf.Series.min用法及代碼示例
- Python cudf.Series.nlargest用法及代碼示例
- Python cudf.Series.to_frame用法及代碼示例
- Python cudf.Series.mask用法及代碼示例
- Python cudf.Series.notnull用法及代碼示例
- Python cudf.Series.isnull用法及代碼示例
注:本文由純淨天空篩選整理自rapids.ai大神的英文原創作品 cudf.Series.from_categorical。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。