cudf.Index.from_pandas#

classmethod Index.from_pandas(index: Index, nan_as_null=_NoDefault.no_default)[source]#

Convert from a Pandas Index.

Parameters:
indexPandas Index object

A Pandas Index object which has to be converted to cuDF Index.

nan_as_nullbool, Default None

If None/True, converts np.nan values to null values. If False, leaves np.nan values as is.

Raises:
TypeError for invalid input type.

Examples

>>> 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)
Index([10.0, 20.0, 30.0, <NA>], dtype='float64')
>>> cudf.Index.from_pandas(pdi, nan_as_null=False)
Index([10.0, 20.0, 30.0, nan], dtype='float64')