>>> import ibis
>>> ibis.dtype("int32")
Int32(nullable=True)
Scalar and column data types
ibis.dtype(value, nullable=True)
Create a DataType object.
Name | Type | Description | Default |
---|---|---|---|
value |
Any | The object to coerce to an Ibis DataType. Supported inputs include strings, python type annotations, numpy dtypes, pandas dtypes, and pyarrow types. | required |
nullable |
bool |
Whether the type should be nullable. Defaults to True. | True |
DataType objects may also be created from Python types:
Or other type systems, like numpy/pandas/pyarrow types:
DataType(self, **kwargs)
Base class for all data types.
Instances are immutable.
Name | Description |
---|---|
name | Return the name of the data type. |
Name | Description |
---|---|
castable | Check whether this type is castable to another. |
from_numpy | Return the equivalent ibis datatype. |
from_pandas | Return the equivalent ibis datatype. |
from_polars | Return the equivalent ibis datatype. |
from_pyarrow | Return the equivalent ibis datatype. |
is_array | Return True if an instance of an Array type. |
is_binary | Return True if an instance of a Binary type. |
is_boolean | Return True if an instance of a Boolean type. |
is_date | Return True if an instance of a Date type. |
is_decimal | Return True if an instance of a Decimal type. |
is_enum | Return True if an instance of an Enum type. |
is_float16 | Return True if an instance of a Float16 type. |
is_float32 | Return True if an instance of a Float32 type. |
is_float64 | Return True if an instance of a Float64 type. |
is_floating | Return True if an instance of any Floating type. |
is_geospatial | Return True if an instance of a Geospatial type. |
is_inet | Return True if an instance of an Inet type. |
is_int16 | Return True if an instance of an Int16 type. |
is_int32 | Return True if an instance of an Int32 type. |
is_int64 | Return True if an instance of an Int64 type. |
is_int8 | Return True if an instance of an Int8 type. |
is_integer | Return True if an instance of any Integer type. |
is_interval | Return True if an instance of an Interval type. |
is_json | Return True if an instance of a JSON type. |
is_linestring | Return True if an instance of a LineString type. |
is_macaddr | Return True if an instance of a MACADDR type. |
is_map | Return True if an instance of a Map type. |
is_multilinestring | Return True if an instance of a MultiLineString type. |
is_multipoint | Return True if an instance of a MultiPoint type. |
is_multipolygon | Return True if an instance of a MultiPolygon type. |
is_nested | Return true if an instance of any nested (Array/Map/Struct) type. |
is_null | Return true if an instance of a Null type. |
is_numeric | Return true if an instance of a Numeric type. |
is_point | Return true if an instance of a Point type. |
is_polygon | Return true if an instance of a Polygon type. |
is_primitive | Return true if an instance of a Primitive type. |
is_signed_integer | Return true if an instance of a SignedInteger type. |
is_string | Return true if an instance of a String type. |
is_struct | Return true if an instance of a Struct type. |
is_temporal | Return true if an instance of a Temporal type. |
is_time | Return true if an instance of a Time type. |
is_timestamp | Return true if an instance of a Timestamp type. |
is_uint16 | Return true if an instance of a UInt16 type. |
is_uint32 | Return true if an instance of a UInt32 type. |
is_uint64 | Return true if an instance of a UInt64 type. |
is_uint8 | Return true if an instance of a UInt8 type. |
is_unknown | Return true if an instance of an Unknown type. |
is_unsigned_integer | Return true if an instance of an UnsignedInteger type. |
is_uuid | Return true if an instance of a UUID type. |
is_variadic | Return true if an instance of a Variadic type. |
to_numpy | Return the equivalent numpy datatype. |
to_pandas | Return the equivalent pandas datatype. |
to_polars | Return the equivalent polars datatype. |
to_pyarrow | Return the equivalent pyarrow datatype. |
castable(to, **kwargs)
Check whether this type is castable to another.
from_numpy(numpy_type, nullable=True)
Return the equivalent ibis datatype.
from_pandas(pandas_type, nullable=True)
Return the equivalent ibis datatype.
from_polars(polars_type, nullable=True)
Return the equivalent ibis datatype.
from_pyarrow(arrow_type, nullable=True)
Return the equivalent ibis datatype.
is_array()
Return True if an instance of an Array type.
is_binary()
Return True if an instance of a Binary type.
is_boolean()
Return True if an instance of a Boolean type.
is_date()
Return True if an instance of a Date type.
is_decimal()
Return True if an instance of a Decimal type.
is_enum()
Return True if an instance of an Enum type.
is_float16()
Return True if an instance of a Float16 type.
is_float32()
Return True if an instance of a Float32 type.
is_float64()
Return True if an instance of a Float64 type.
is_floating()
Return True if an instance of any Floating type.
is_geospatial()
Return True if an instance of a Geospatial type.
is_inet()
Return True if an instance of an Inet type.
is_int16()
Return True if an instance of an Int16 type.
is_int32()
Return True if an instance of an Int32 type.
is_int64()
Return True if an instance of an Int64 type.
is_int8()
Return True if an instance of an Int8 type.
is_integer()
Return True if an instance of any Integer type.
is_interval()
Return True if an instance of an Interval type.
is_json()
Return True if an instance of a JSON type.
is_linestring()
Return True if an instance of a LineString type.
is_macaddr()
Return True if an instance of a MACADDR type.
is_map()
Return True if an instance of a Map type.
is_multilinestring()
Return True if an instance of a MultiLineString type.
is_multipoint()
Return True if an instance of a MultiPoint type.
is_multipolygon()
Return True if an instance of a MultiPolygon type.
is_nested()
Return true if an instance of any nested (Array/Map/Struct) type.
is_null()
Return true if an instance of a Null type.
is_numeric()
Return true if an instance of a Numeric type.
is_point()
Return true if an instance of a Point type.
is_polygon()
Return true if an instance of a Polygon type.
is_primitive()
Return true if an instance of a Primitive type.
is_signed_integer()
Return true if an instance of a SignedInteger type.
is_string()
Return true if an instance of a String type.
is_struct()
Return true if an instance of a Struct type.
is_temporal()
Return true if an instance of a Temporal type.
is_time()
Return true if an instance of a Time type.
is_timestamp()
Return true if an instance of a Timestamp type.
is_uint16()
Return true if an instance of a UInt16 type.
is_uint32()
Return true if an instance of a UInt32 type.
is_uint64()
Return true if an instance of a UInt64 type.
is_uint8()
Return true if an instance of a UInt8 type.
is_unknown()
Return true if an instance of an Unknown type.
is_unsigned_integer()
Return true if an instance of an UnsignedInteger type.
is_uuid()
Return true if an instance of a UUID type.
is_variadic()
Return true if an instance of a Variadic type.
to_numpy()
Return the equivalent numpy datatype.
to_pandas()
Return the equivalent pandas datatype.
to_polars()
Return the equivalent polars datatype.
to_pyarrow()
Return the equivalent pyarrow datatype.
Array(self, **kwargs)
Array values.
Binary(self, **kwargs)
A type representing a sequence of bytes.
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(self, **kwargs)
Date(self, **kwargs)
Date values.
Decimal(self, precision=None, scale=None, **kwargs)
Fixed-precision decimal values.
Name | Description |
---|---|
precision | The number of decimal places values of this type can hold. |
scale | The number of values after the decimal point. |
Float16(self, **kwargs)
16-bit floating point numbers.
Float32(self, **kwargs)
32-bit floating point numbers.
Float64(self, **kwargs)
64-bit floating point numbers.
INET(self, **kwargs)
IP addresses.
Int16(self, **kwargs)
Signed 16-bit integers.
Int32(self, **kwargs)
Signed 32-bit integers.
Int64(self, **kwargs)
Signed 64-bit integers.
Int8(self, **kwargs)
Signed 8-bit integers.
Interval(self, **kwargs)
Interval values.
Name | Description |
---|---|
resolution | The interval unit’s name. |
unit | The time unit of the interval. |
JSON(self, **kwargs)
JSON values.
Name | Description |
---|---|
binary | True if JSON is stored as binary, e.g., JSONB in PostgreSQL. |
LineString(self, **kwargs)
A sequence of 2 or more points.
MACADDR(self, **kwargs)
Media Access Control (MAC) address of a network interface.
Map(self, **kwargs)
Associative array values.
MultiLineString(self, **kwargs)
A set of one or more line strings.
MultiPoint(self, **kwargs)
A set of one or more points.
MultiPolygon(self, **kwargs)
A set of one or more polygons.
Null(self, **kwargs)
Null values.
Point(self, **kwargs)
A point described by two coordinates.
Polygon(self, **kwargs)
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).
String(self, **kwargs)
A type representing a string.
Because of differences in the way different backends handle strings, we cannot assume that strings are UTF-8 encoded.
Struct(self, **kwargs)
Structured values.
Name | Description |
---|---|
from_tuples | Construct a Struct type from pairs. |
names | Return the names of the struct’s fields. |
types | Return the types of the struct’s fields. |
from_tuples(pairs, nullable=True)
Construct a Struct
type from pairs.
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 |
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.
Time(self, **kwargs)
Time values.
Timestamp(self, **kwargs)
Timestamp values.
Name | Description |
---|---|
scale | The scale of the timestamp if known. |
timezone | The timezone of values of this type. |
unit | Return the unit of the timestamp. |
Name | Description |
---|---|
from_unit | Return a timestamp type with the given unit and timezone. |
from_unit(unit, timezone=None, nullable=True)
Return a timestamp type with the given unit and timezone.
UInt16(self, **kwargs)
Unsigned 16-bit integers.
UInt32(self, **kwargs)
Unsigned 32-bit integers.
UInt64(self, **kwargs)
Unsigned 64-bit integers.
UInt8(self, **kwargs)
Unsigned 8-bit integers.
UUID(self, **kwargs)
A 128-bit number used to identify information in computer systems.