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
¶
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.
Bounds
¶
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.
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_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.
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.
Floating
¶
GeoSpatial
¶
Int16
¶
Int32
¶
Int64
¶
Int8
¶
Integer
¶
Interval
¶
Bases: Parametric
Interval values.
LineString
¶
Map
¶
MultiLineString
¶
MultiPoint
¶
MultiPolygon
¶
Point
¶
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).
SignedInteger
¶
String
¶
Struct
¶
Bases: Parametric
, MapSet
Structured 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
¶
UInt32
¶
UInt64
¶
UInt8
¶
UnsignedInteger
¶
Functions¶
dtype(value, nullable=True)
¶
Create a DataType object.
Parameters:
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
|
Examples:
>>> import ibis
>>> ibis.dtype("int32")
Int32(nullable=True)
>>> ibis.dtype("array<float>")
Array(value_type=Float64(nullable=True), nullable=True)
DataType objects may also be created from Python types:
>>> ibis.dtype(int)
Int64(nullable=True)
>>> ibis.dtype(list[float])
Array(value_type=Float64(nullable=True), nullable=True)
Or other type systems, like numpy/pandas/pyarrow types:
>>> import pyarrow as pa
>>> ibis.dtype(pa.int32())
Int32(nullable=True)