用法:
classmethod Index.from_pandas(index, nan_as_null=None)
從 Pandas 索引轉換。
- index: Pandas 索引對象
必須轉換為 cuDF 索引的 Pandas 索引對象。
- nan_as_null:布爾,默認無
如果
None
/True
,將np.nan
值轉換為null
值。如果False
,保持np.nan
值不變。
- 無效輸入類型的 TypeError。
參數:
拋出:
例子:
>>> import cudf >>> import pandas as pd >>> import numpy as np >>> data = [10, 20, 30, np.nan] >>> pdi = pd.Index(data) >>> cudf.Index.from_pandas(pdi) Float64Index([10.0, 20.0, 30.0, <NA>], dtype='float64') >>> cudf.Index.from_pandas(pdi, nan_as_null=False) Float64Index([10.0, 20.0, 30.0, nan], dtype='float64')
相關用法
- Python cudf.Index.fillna用法及代碼示例
- Python cudf.Index.is_boolean用法及代碼示例
- Python cudf.Index.astype用法及代碼示例
- Python cudf.Index.set_names用法及代碼示例
- Python cudf.Index.is_numeric用法及代碼示例
- Python cudf.Index.sort_values用法及代碼示例
- Python cudf.Index.union用法及代碼示例
- Python cudf.Index.is_integer用法及代碼示例
- Python cudf.Index.join用法及代碼示例
- Python cudf.Index.get_level_values用法及代碼示例
- Python cudf.Index.isin用法及代碼示例
- Python cudf.Index.rename用法及代碼示例
- Python cudf.Index.to_pandas用法及代碼示例
- Python cudf.Index.difference用法及代碼示例
- Python cudf.Index.is_object用法及代碼示例
- Python cudf.Index.is_categorical用法及代碼示例
- Python cudf.Index.append用法及代碼示例
- Python cudf.Index.is_interval用法及代碼示例
- Python cudf.Index.intersection用法及代碼示例
- Python cudf.Index.is_floating用法及代碼示例
注:本文由純淨天空篩選整理自rapids.ai大神的英文原創作品 cudf.Index.from_pandas。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。