NestedDtype#
- class NestedDtype(pyarrow_dtype: DataType | Mapping)[source]#
Data type to handle packed time series data
- Parameters:
pyarrow_dtype (pyarrow.StructType, pd.ArrowDtype, or Mapping[str, pa.DataType]) – The pyarrow data type to use for the nested type. It may be provided as a pyarrow.StructType, a pandas.ArrowDtype, or a mapping of column names to pyarrow data types (such as a dictionary).
Examples
>>> import pyarrow as pa >>> from nested_pandas import NestedDtype
From pa.StructType:
>>> dtype = NestedDtype(pa.struct([pa.field("a", pa.list_(pa.int64())), ... pa.field("b", pa.list_(pa.float64()))])) >>> dtype nested<a: [int64], b: [double]>
From pd.ArrowDtype:
>>> import pandas as pd >>> dtype = NestedDtype(pd.ArrowDtype(pa.struct([pa.field("a", pa.list_(pa.int64())), ... pa.field("b", pa.list_(pa.float64()))]))) >>> dtype nested<a: [int64], b: [double]>
From mapping of column names to pyarrow data types:
>>> dtype = NestedDtype({"a": pa.int64(), "b": pa.float64()}) >>> dtype nested<a: [int64], b: [double]>
Methods
__init__(pyarrow_dtype)column_dtype(column)Pandas dtype of a column, pd.ArrowDType or NestedDtype.
Corresponded array type, always NestedExtensionArray
construct_from_string(string)Construct NestedDtype from a string representation.
empty(shape)Construct an ExtensionArray of this dtype with the given shape.
field_dtype(field)Pandas dtype of a field, pd.ArrowDType or NestedDtype.
from_columns(columns)Make NestedDtype from a mapping of column names and list item types.
from_fields(fields)Make NestedDtype from a mapping of field names and list item types.
from_pandas_arrow_dtype(pandas_arrow_dtype)Construct NestedDtype from a pandas.ArrowDtype.
is_dtype(dtype)Check if we match 'dtype'.
to_pandas_arrow_dtype([list_struct])Convert NestedDtype to a pandas.ArrowDtype.
Attributes
column_dtypesThe mapping of field names and their item types.
field_dtypesPandas dtypes of this dtype's fields.
field_namesThe list of field names of the nested type
fieldsThe mapping of field names and their item types.
index_classThe Index subclass to return from Index.__new__ when this dtype is encountered.
kindA character code (one of 'biufcmMOSUV'), default 'O'
na_valueThe missing value for this dtype
nameThe string representation of the nested type
namesOrdered list of field names, or None if there are no fields.
struct_list_pa_dtypeStruct-list pyarrow type representing the nested type.
pyarrow_dtype