Skip to content

DataType

arro3.core.DataType

An Arrow DataType.

bit_width property

bit_width: int | None

list_size property

list_size: int | None

The size of the list in the case of fixed size lists.

This will return None if the data type is not a fixed size list.

Examples:

from arro3.core import DataType
DataType.list(DataType.int32(), 2).list_size
# 2

Returns:

  • int | None

    description

num_fields property

num_fields: int

The number of child fields.

value_type property

value_type: DataType | None

__arrow_c_schema__

__arrow_c_schema__() -> object

An implementation of the Arrow PyCapsule Interface. This dunder method should not be called directly, but enables zero-copy data transfer to other Python libraries that understand Arrow memory.

For example, you can call pyarrow.field() to convert this array into a pyarrow field, without copying memory.

binary classmethod

binary(length: int | None = None) -> DataType

Create variable-length or fixed size binary type.

Parameters:

  • length (int | None, default: None ) –

    If length is None then return a variable length binary type. If length is provided, then return a fixed size binary type of width length. Defaults to None.

Returns:

binary_view classmethod

binary_view() -> DataType

Create a variable-length binary view type.

bool classmethod

bool() -> DataType

Create instance of boolean type.

date32 classmethod

date32() -> DataType

Create instance of 32-bit date (days since UNIX epoch 1970-01-01).

date64 classmethod

date64() -> DataType

Create instance of 64-bit date (milliseconds since UNIX epoch 1970-01-01).

decimal128 classmethod

decimal128(precision: int, scale: int) -> DataType

Create decimal type with precision and scale and 128-bit width.

Arrow decimals are fixed-point decimal numbers encoded as a scaled integer. The precision is the number of significant digits that the decimal type can represent; the scale is the number of digits after the decimal point (note the scale can be negative).

As an example, decimal128(7, 3) can exactly represent the numbers 1234.567 and -1234.567 (encoded internally as the 128-bit integers 1234567 and -1234567, respectively), but neither 12345.67 nor 123.4567.

decimal128(5, -3) can exactly represent the number 12345000 (encoded internally as the 128-bit integer 12345), but neither 123450000 nor 1234500.

If you need a precision higher than 38 significant digits, consider using decimal256.

Parameters:

  • precision (int) –

    Must be between 1 and 38 scale: description

decimal256 classmethod

decimal256(precision: int, scale: int) -> DataType

Create decimal type with precision and scale and 256-bit width.

dictionary classmethod

dictionary(
    index_type: ArrowSchemaExportable, value_type: ArrowSchemaExportable
) -> DataType

Dictionary (categorical, or simply encoded) type.

Parameters:

Returns:

duration classmethod

duration(unit: Literal['s', 'ms', 'us', 'ns']) -> DataType

Create instance of a duration type with unit resolution.

Parameters:

  • unit (Literal['s', 'ms', 'us', 'ns']) –

    one of 's' [second], 'ms' [millisecond], 'us' [microsecond], or 'ns' [nanosecond]

Returns:

equals

equals(other: ArrowSchemaExportable, *, check_metadata: bool = False) -> bool

Return true if type is equivalent to passed value.

Parameters:

  • other (ArrowSchemaExportable) –

    description

  • check_metadata (bool, default: False ) –

    Whether nested Field metadata equality should be checked as well. Defaults to False.

Returns:

  • bool

    description

float16 classmethod

float16() -> DataType

Create half-precision floating point type.

float32 classmethod

float32() -> DataType

Create single-precision floating point type.

float64 classmethod

float64() -> DataType

Create double-precision floating point type.

from_arrow classmethod

from_arrow(input: ArrowSchemaExportable) -> DataType

Construct this from an existing Arrow object.

It can be called on anything that exports the Arrow schema interface (has an __arrow_c_schema__ method).

from_arrow_pycapsule classmethod

from_arrow_pycapsule(capsule) -> DataType

Construct this object from a bare Arrow PyCapsule

int16 classmethod

int16() -> DataType

Create instance of signed int16 type.

int32 classmethod

int32() -> DataType

Create instance of signed int32 type.

int64 classmethod

int64() -> DataType

Create instance of signed int64 type.

int8 classmethod

int8() -> DataType

Create instance of signed int8 type.

is_binary staticmethod

is_binary(t: ArrowSchemaExportable) -> bool

is_binary_view staticmethod

is_binary_view(t: ArrowSchemaExportable) -> bool

is_boolean staticmethod

is_boolean(t: ArrowSchemaExportable) -> bool

is_date staticmethod

is_date(t: ArrowSchemaExportable) -> bool

is_date32 staticmethod

is_date32(t: ArrowSchemaExportable) -> bool

is_date64 staticmethod

is_date64(t: ArrowSchemaExportable) -> bool

is_decimal staticmethod

is_decimal(t: ArrowSchemaExportable) -> bool

is_decimal128 staticmethod

is_decimal128(t: ArrowSchemaExportable) -> bool

is_decimal256 staticmethod

is_decimal256(t: ArrowSchemaExportable) -> bool

is_dictionary staticmethod

is_dictionary(t: ArrowSchemaExportable) -> bool

is_dictionary_key_type staticmethod

is_dictionary_key_type(t: ArrowSchemaExportable) -> bool

is_duration staticmethod

is_duration(t: ArrowSchemaExportable) -> bool

is_fixed_size_binary staticmethod

is_fixed_size_binary(t: ArrowSchemaExportable) -> bool

is_fixed_size_list staticmethod

is_fixed_size_list(t: ArrowSchemaExportable) -> bool

is_float16 staticmethod

is_float16(t: ArrowSchemaExportable) -> bool

is_float32 staticmethod

is_float32(t: ArrowSchemaExportable) -> bool

is_float64 staticmethod

is_float64(t: ArrowSchemaExportable) -> bool

is_floating staticmethod

is_floating(t: ArrowSchemaExportable) -> bool

is_int16 staticmethod

is_int16(t: ArrowSchemaExportable) -> bool

is_int32 staticmethod

is_int32(t: ArrowSchemaExportable) -> bool

is_int64 staticmethod

is_int64(t: ArrowSchemaExportable) -> bool

is_int8 staticmethod

is_int8(t: ArrowSchemaExportable) -> bool

is_integer staticmethod

is_integer(t: ArrowSchemaExportable) -> bool

is_interval staticmethod

is_interval(t: ArrowSchemaExportable) -> bool

is_large_binary staticmethod

is_large_binary(t: ArrowSchemaExportable) -> bool

is_large_list staticmethod

is_large_list(t: ArrowSchemaExportable) -> bool

is_large_list_view staticmethod

is_large_list_view(t: ArrowSchemaExportable) -> bool

is_large_string staticmethod

is_large_string(t: ArrowSchemaExportable) -> bool

is_large_unicode staticmethod

is_large_unicode(t: ArrowSchemaExportable) -> bool

is_list staticmethod

is_list(t: ArrowSchemaExportable) -> bool

is_list_view staticmethod

is_list_view(t: ArrowSchemaExportable) -> bool

is_map staticmethod

is_nested staticmethod

is_nested(t: ArrowSchemaExportable) -> bool

is_null staticmethod

is_null(t: ArrowSchemaExportable) -> bool

is_numeric staticmethod

is_numeric(t: ArrowSchemaExportable) -> bool

is_primitive staticmethod

is_primitive(t: ArrowSchemaExportable) -> bool

is_run_end_encoded staticmethod

is_run_end_encoded(t: ArrowSchemaExportable) -> bool

is_signed_integer staticmethod

is_signed_integer(t: ArrowSchemaExportable) -> bool

is_string staticmethod

is_string(t: ArrowSchemaExportable) -> bool

is_string_view staticmethod

is_string_view(t: ArrowSchemaExportable) -> bool

is_struct staticmethod

is_struct(t: ArrowSchemaExportable) -> bool

is_temporal staticmethod

is_temporal(t: ArrowSchemaExportable) -> bool

is_time staticmethod

is_time(t: ArrowSchemaExportable) -> bool

is_time32 staticmethod

is_time32(t: ArrowSchemaExportable) -> bool

is_time64 staticmethod

is_time64(t: ArrowSchemaExportable) -> bool

is_timestamp staticmethod

is_timestamp(t: ArrowSchemaExportable) -> bool

is_uint16 staticmethod

is_uint16(t: ArrowSchemaExportable) -> bool

is_uint32 staticmethod

is_uint32(t: ArrowSchemaExportable) -> bool

is_uint64 staticmethod

is_uint64(t: ArrowSchemaExportable) -> bool

is_uint8 staticmethod

is_uint8(t: ArrowSchemaExportable) -> bool

is_unicode staticmethod

is_unicode(t: ArrowSchemaExportable) -> bool

is_union staticmethod

is_union(t: ArrowSchemaExportable) -> bool

is_unsigned_integer staticmethod

is_unsigned_integer(t: ArrowSchemaExportable) -> bool

large_binary classmethod

large_binary() -> DataType

Create large variable-length binary type.

large_list classmethod

large_list(value_type: ArrowSchemaExportable) -> DataType

Create LargeListType instance from child data type or field.

This data type may not be supported by all Arrow implementations. Unless you need to represent data larger than 2**31 elements, you should prefer list().

Parameters:

Returns:

large_list_view classmethod

large_list_view(value_type: ArrowSchemaExportable) -> DataType

Create LargeListViewType instance from child data type or field.

This data type may not be supported by all Arrow implementations because it is an alternative to the ListType.

Parameters:

Returns:

large_string classmethod

large_string() -> DataType

Create large UTF8 variable-length string type.

large_utf8 classmethod

large_utf8() -> DataType

Alias for large_string().

list classmethod

list(
    value_type: ArrowSchemaExportable, list_size: int | None = None
) -> DataType

Create ListType instance from child data type or field.

Parameters:

  • value_type (ArrowSchemaExportable) –

    description

  • list_size (int | None, default: None ) –

    If length is None then return a variable length list type. If length is provided then return a fixed size list type.

Returns:

list_view classmethod

list_view(value_type: ArrowSchemaExportable) -> DataType

Create ListViewType instance from child data type or field.

This data type may not be supported by all Arrow implementations because it is an alternative to the ListType.

map classmethod

map(
    key_type: ArrowSchemaExportable,
    item_type: ArrowSchemaExportable,
    keys_sorted: bool,
) -> DataType

Create MapType instance from key and item data types or fields.

Parameters:

Returns:

month_day_nano_interval classmethod

month_day_nano_interval() -> DataType

Create instance of an interval type representing months, days and nanoseconds between two dates.

null classmethod

null() -> DataType

Create instance of null type.

run_end_encoded classmethod

run_end_encoded(
    run_end_type: ArrowSchemaExportable, value_type: ArrowSchemaExportable
) -> DataType

Create RunEndEncodedType from run-end and value types.

Parameters:

Returns:

string classmethod

string() -> DataType

Create UTF8 variable-length string type.

string_view classmethod

string_view() -> DataType

Create UTF8 variable-length string view type.

struct classmethod

Create StructType instance from fields.

A struct is a nested type parameterized by an ordered sequence of types (which can all be distinct), called its fields.

Parameters:

Returns:

time32 classmethod

time32(unit: Literal['s', 'ms']) -> DataType

Create instance of 32-bit time (time of day) type with unit resolution.

Parameters:

  • unit (Literal['s', 'ms']) –

    one of 's' [second], or 'ms' [millisecond]

Returns:

time64 classmethod

time64(unit: Literal['us', 'ns']) -> DataType

Create instance of 64-bit time (time of day) type with unit resolution.

Parameters:

  • unit (Literal['us', 'ns']) –

    One of 'us' [microsecond], or 'ns' [nanosecond].

Returns:

timestamp classmethod

timestamp(
    unit: Literal["s", "ms", "us", "ns"], *, tz: str | None = None
) -> DataType

Create instance of timestamp type with resolution and optional time zone.

Parameters:

  • unit (Literal['s', 'ms', 'us', 'ns']) –

    one of 's' [second], 'ms' [millisecond], 'us' [microsecond], or 'ns' [nanosecond]

  • tz (str | None, default: None ) –

    Time zone name. None indicates time zone naive. Defaults to None.

Returns:

uint16 classmethod

uint16() -> DataType

Create instance of unsigned int16 type.

uint32 classmethod

uint32() -> DataType

Create instance of unsigned int32 type.

uint64 classmethod

uint64() -> DataType

Create instance of unsigned int64 type.

uint8 classmethod

uint8() -> DataType

Create instance of unsigned int8 type.

utf8 classmethod

utf8() -> DataType

Alias for string().