API

Public

class pydiverse.common.Dtype[source]

Base class for all data types.

classmethod is_int()[source]

Return True if this dtype is an integer type.

classmethod is_float()[source]

Return True if this dtype is a float type.

classmethod is_subtype(rhs)[source]

Return True if this dtype is a subtype of rhs.

For example, Int8.is_subtype(Int()) is True.

static from_sql(sql_type) Dtype[source]

Convert a SQL type to a Dtype.

static from_pandas(pandas_type) Dtype[source]

Convert a pandas type to a Dtype.

static from_arrow(arrow_type) Dtype[source]

Convert a PyArrow type to a Dtype.

static from_polars(polars_type) Dtype[source]

Convert a Polars type to a Dtype.

to_sql()[source]

Convert this Dtype to a SQL type.

to_pandas(backend: PandasBackend = PandasBackend.ARROW)[source]

Convert this Dtype to a pandas type.

to_pandas_nullable(backend: PandasBackend = PandasBackend.ARROW)[source]

Convert this Dtype to a pandas nullable type.

Nullable can be either pandas extension types like StringDtype or ArrowDtype.

Parameters:

backend (PandasBackend, optional) – The pandas backend to use. Defaults to PandasBackend.ARROW. If PandasBackend.NUMPY is selected, this method will attempt to return a NumPy-backed nullable pandas dtype. Note that Time, NullType, and List will raise a TypeError for the NUMPY backend as pandas doesn’t have corresponding native nullable dtypes for these.

to_arrow()[source]

Convert this Dtype to a PyArrow type.

to_arrow_field(name: str, nullable: bool = True)[source]

Convert this Dtype to a PyArrow Field.

to_polars()[source]

Convert this Dtype to a Polars type.

class pydiverse.common.Bool[source]
class pydiverse.common.Date[source]
class pydiverse.common.Datetime[source]
class pydiverse.common.Decimal(precision: int | None = None, scale: int | None = None)[source]
to_sql()[source]

Convert this Dtype to a SQL type.

to_polars()[source]

Convert this Dtype to a Polars type.

to_arrow()[source]

Convert this Dtype to a PyArrow type.

class pydiverse.common.Duration[source]
class pydiverse.common.Float[source]
classmethod is_float()[source]

Return True if this dtype is a float type.

class pydiverse.common.Float32[source]
class pydiverse.common.Float64[source]
class pydiverse.common.Int[source]
classmethod is_int()[source]

Return True if this dtype is an integer type.

class pydiverse.common.Int8[source]
class pydiverse.common.Int16[source]
class pydiverse.common.Int32[source]
class pydiverse.common.Int64[source]
class pydiverse.common.NullType[source]
class pydiverse.common.String(max_length: int | None = None)[source]
to_sql()[source]

Convert this Dtype to a SQL type.

to_polars()[source]

Convert this Dtype to a Polars type.

to_arrow()[source]

Convert this Dtype to a PyArrow type.

class pydiverse.common.Time[source]
class pydiverse.common.UInt8[source]
class pydiverse.common.UInt16[source]
class pydiverse.common.UInt32[source]
class pydiverse.common.UInt64[source]
class pydiverse.common.List(inner: pydiverse.common.dtypes.Dtype)[source]
to_sql()[source]

Convert this Dtype to a SQL type.

to_polars()[source]

Convert this Dtype to a Polars type.

to_arrow()[source]

Convert this Dtype to a PyArrow type.

class pydiverse.common.PandasBackend(*values)[source]