cudf.ListDtype#
- class cudf.ListDtype(element_type: Any)#
Type to represent list data.
- Parameters
- element_typeobject
A dtype with which represents the element types in the list.
Examples
>>> import cudf >>> list_dtype = cudf.ListDtype("int32") >>> list_dtype ListDtype(int32)
A nested list dtype can be created by:
>>> nested_list_dtype = cudf.ListDtype(list_dtype) >>> nested_list_dtype ListDtype(ListDtype(int32))
Attributes
element_type
Returns the element type of the
ListDtype
. Returns ——- Dtype Examples ——– >>> import cudf >>> deep_nested_type = cudf.ListDtype(cudf.ListDtype(cudf.ListDtype(“float32”))) >>> deep_nested_type ListDtype(ListDtype(ListDtype(float32))) >>> deep_nested_type.element_type ListDtype(ListDtype(float32)) >>> deep_nested_type.element_type.element_type ListDtype(float32) >>> deep_nested_type.element_type.element_type.element_type ‘float32’leaf_type
Returns the type of the leaf values. Examples ——– >>> import cudf >>> deep_nested_type = cudf.ListDtype(cudf.ListDtype(cudf.ListDtype(“float32”))) >>> deep_nested_type ListDtype(ListDtype(ListDtype(float32))) >>> deep_nested_type.leaf_type ‘float32’
Methods
from_arrow
(typ)Creates a
ListDtype
frompyarrow.ListType
.to_arrow
()Convert to a
pyarrow.ListType
- property element_type: Union[ExtensionDtype, str, dtype]#
Returns the element type of the
ListDtype
.- Returns
- Dtype
Examples
>>> import cudf >>> deep_nested_type = cudf.ListDtype(cudf.ListDtype(cudf.ListDtype("float32"))) >>> deep_nested_type ListDtype(ListDtype(ListDtype(float32))) >>> deep_nested_type.element_type ListDtype(ListDtype(float32)) >>> deep_nested_type.element_type.element_type ListDtype(float32) >>> deep_nested_type.element_type.element_type.element_type 'float32'
- classmethod from_arrow(typ)#
Creates a
ListDtype
frompyarrow.ListType
.- Parameters
- typpyarrow.ListType
A
pyarrow.ListType
that has to be converted toListDtype
.
- Returns
- obj
ListDtype
- obj
Examples
>>> import cudf >>> import pyarrow as pa >>> arrow_type = pa.infer_type([[1]]) >>> arrow_type ListType(list<item: int64>) >>> list_dtype = cudf.ListDtype.from_arrow(arrow_type) >>> list_dtype ListDtype(int64)
- property leaf_type#
Returns the type of the leaf values.
Examples
>>> import cudf >>> deep_nested_type = cudf.ListDtype(cudf.ListDtype(cudf.ListDtype("float32"))) >>> deep_nested_type ListDtype(ListDtype(ListDtype(float32))) >>> deep_nested_type.leaf_type 'float32'
- to_arrow()#
Convert to a
pyarrow.ListType
Examples
>>> import cudf >>> list_dtype = cudf.ListDtype(cudf.ListDtype("float32")) >>> list_dtype ListDtype(ListDtype(float32)) >>> list_dtype.to_arrow() ListType(list<item: list<item: float>>)