Skip to content

Data Types

This module contains classes for handling the different logical types that occur in databases.

All data type constructors take a nullable: bool parameter whose default value is True.

core

Classes

Array

Bases: Variadic, Parametric

Array values.

Binary

Bases: Variadic, Singleton

A type representing a sequence of bytes.

Notes

Some databases treat strings and blobs of equally, and some do not.

For example, Impala doesn't make a distinction between string and binary types but PostgreSQL has a TEXT type and a BYTEA type which are distinct types that have different behavior.

Boolean

Bases: Primitive

True or False values.

Bounds

Bases: NamedTuple

The lower and upper bound of a fixed-size value.

DataType

Bases: Concrete, Coercible

Base class for all data types.

DataType instances are immutable.

Attributes
name: str property

Return the name of the data type.

Functions
from_dask(dask_type, nullable=True) classmethod

Return the equivalent ibis datatype.

from_numpy(numpy_type, nullable=True) classmethod

Return the equivalent ibis datatype.

from_pandas(pandas_type, nullable=True) classmethod

Return the equivalent ibis datatype.

from_pyarrow(arrow_type, nullable=True) classmethod

Return the equivalent ibis datatype.

to_dask()

Return the equivalent dask datatype.

to_numpy()

Return the equivalent numpy datatype.

to_pandas()

Return the equivalent pandas datatype.

to_pyarrow()

Return the equivalent pyarrow datatype.

Date

Bases: Temporal, Primitive

Date values.

Decimal

Bases: Numeric, Parametric

Fixed-precision decimal values.

Attributes
largest property

Return the largest type of decimal.

precision: Optional[int] = None class-attribute instance-attribute

The number of decimal places values of this type can hold.

scale: Optional[int] = None class-attribute instance-attribute

The number of values after the decimal point.

Float16

Bases: Floating

16-bit floating point numbers.

Float32

Bases: Floating

32-bit floating point numbers.

Float64

Bases: Floating

64-bit floating point numbers.

Floating

Bases: Primitive, Numeric

Floating point values.

Attributes
largest property

Return the largest type of floating point values.

GeoSpatial

Bases: DataType

Geospatial values.

Attributes
geotype: Optional[Literal['geography', 'geometry']] = None class-attribute instance-attribute

The specific geospatial type.

srid: Optional[int] = None class-attribute instance-attribute

The spatial reference identifier.

INET

Bases: String

IP addresses.

Int16

Bases: SignedInteger

Signed 16-bit integers.

Int32

Bases: SignedInteger

Signed 32-bit integers.

Int64

Bases: SignedInteger

Signed 64-bit integers.

Int8

Bases: SignedInteger

Signed 8-bit integers.

Integer

Bases: Primitive, Numeric

Integer values.

Attributes
nbytes: int abstractmethod property

Return the number of bytes used to store values of this type.

Interval

Bases: Parametric

Interval values.

Attributes
resolution property

The interval unit's name.

unit: IntervalUnit = 's' class-attribute instance-attribute

The time unit of the interval.

JSON

Bases: Variadic

JSON values.

LineString

Bases: GeoSpatial

A sequence of 2 or more points.

MACADDR

Bases: String

Media Access Control (MAC) address of a network interface.

Map

Bases: Variadic, Parametric

Associative array values.

MultiLineString

Bases: GeoSpatial

A set of one or more line strings.

MultiPoint

Bases: GeoSpatial

A set of one or more points.

MultiPolygon

Bases: GeoSpatial

A set of one or more polygons.

Null

Bases: Primitive

Null values.

Numeric

Bases: DataType

Numeric types.

Parametric

Bases: DataType

Types that can be parameterized.

Point

Bases: GeoSpatial

A point described by two coordinates.

Polygon

Bases: GeoSpatial

A set of one or more closed line strings.

The first line string represents the shape (external ring) and the rest represent holes in that shape (internal rings).

Primitive

Bases: DataType, Singleton

Values with known size.

SignedInteger

Bases: Integer

Signed integer values.

Attributes
largest property

Return the largest type of signed integer.

String

Bases: Variadic, Singleton

A type representing a string.

Notes

Because of differences in the way different backends handle strings, we cannot assume that strings are UTF-8 encoded.

Struct

Bases: Parametric, MapSet

Structured values.

Functions
from_tuples(pairs, nullable=True) classmethod

Construct a Struct type from pairs.

Parameters:

Name Type Description Default
pairs Iterable[tuple[str, str | DataType]]

An iterable of pairs of field name and type

required
nullable bool

Whether the type is nullable

True

Returns:

Type Description
Struct

Struct data type instance

names()

Return the names of the struct's fields.

types()

Return the types of the struct's fields.

Temporal

Bases: DataType

Data types related to time.

Time

Bases: Temporal, Primitive

Time values.

Timestamp

Bases: Temporal, Parametric

Timestamp values.

Attributes
scale: Optional[Literal[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]] = None class-attribute instance-attribute

The scale of the timestamp if known.

timezone: Optional[str] = None class-attribute instance-attribute

The timezone of values of this type.

unit: str property

Return the unit of the timestamp.

Functions
from_unit(unit, timezone=None, nullable=True) classmethod

Return a timestamp type with the given unit and timezone.

UInt16

Bases: UnsignedInteger

Unsigned 16-bit integers.

UInt32

Bases: UnsignedInteger

Unsigned 32-bit integers.

UInt64

Bases: UnsignedInteger

Unsigned 64-bit integers.

UInt8

Bases: UnsignedInteger

Unsigned 8-bit integers.

UUID

Bases: DataType

A 128-bit number used to identify information in computer systems.

Unknown

Bases: DataType, Singleton

An unknown type.

UnsignedInteger

Bases: Integer

Unsigned integer values.

Attributes
largest property

Return the largest type of unsigned integer.

Variadic

Bases: DataType

Values with unknown size.

Functions

dtype(value, nullable=True)

Construct an ibis datatype from a python type.


Last update: August 5, 2022