Data Types¶
This module contains classes for handling the different storage types that occur in databases.
All data type constructors take a nullable: bool
parameter whose default
value is True
.
datatypes
special
¶
Modules¶
core
¶
Classes¶
DataType (Annotable, Comparable)
¶
Base class for all data types.
DataType
instances are
immutable.
name: str
property
readonly
¶Return the name of the data type.
cast(self, target, **kwargs)
¶Cast this data type to target
.
castable(self, target, **kwargs)
¶Return whether this data type is castable to target
.
to_pandas(ibis_dtype)
¶Convert ibis dtype to the pandas / numpy alternative
Geography (GeoSpatial)
¶
Geography values.
Geometry (GeoSpatial)
¶
Geometry values.
Int16 (SignedInteger)
¶
Signed 16-bit integers.
Int32 (SignedInteger)
¶
Signed 32-bit integers.
Int64 (SignedInteger)
¶
Signed 64-bit integers.
Int8 (SignedInteger)
¶
Signed 8-bit integers.
JSONB (Binary)
¶
JSON data stored in a binary representation.
This representation eliminates whitespace, duplicate keys, and does not preserve key ordering.
LineString (GeoSpatial)
¶
A sequence of 2 or more points.
MultiLineString (GeoSpatial)
¶
A set of one or more line strings.
MultiPoint (GeoSpatial)
¶
A set of one or more points.
MultiPolygon (GeoSpatial)
¶
A set of one or more polygons.
Point (GeoSpatial)
¶
A point described by two coordinates.
Polygon (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).
Struct (DataType)
¶
Structured values.
pairs: Mapping[str, DataType]
property
readonly
¶Return a mapping from names to data type instances.
Returns:
Type | Description |
---|---|
Mapping[str, DataType] |
Mapping of field name to data type |
from_dict(pairs, nullable=True)
classmethod
¶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 |
Returns:
Type | Description |
---|---|
Struct |
Struct data type instance |
UInt16 (UnsignedInteger)
¶
Unsigned 16-bit integers.
UInt32 (UnsignedInteger)
¶
Unsigned 32-bit integers.
UInt64 (UnsignedInteger)
¶
Unsigned 64-bit integers.
UInt8 (UnsignedInteger)
¶
Unsigned 8-bit integers.
Functions¶
cast(source, target, **kwargs)
¶
Attempts to implicitly cast from source dtype to target dtype
parse_type(text)
¶
Parse a type from a str
text
.
The default maxsize
parameter for caching is chosen to cache the most
commonly used types--there are about 30--along with some capacity for less
common but repeatedly-used complex types.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
text |
str |
The type string to parse |
required |
Examples:
Parse an array type from a string
>>> import ibis
>>> import ibis.expr.datatypes as dt
>>> dt.parse_type("array<int64>")
Array(value_type=Int64(nullable=True), nullable=True)
You can avoid parsing altogether by constructing objects directly
>>> import ibis
>>> import ibis.expr.datatypes as dt
>>> ty = dt.parse_type("array<int64>")
>>> ty == dt.Array(dt.int64)
True