>>> from ibis import schema, Schema
>>> sc = schema([("foo", "string"), ("bar", "int64"), ("baz", "boolean")])
>>> sc = schema(names=["foo", "bar", "baz"], types=["string", "int64", "boolean"])
>>> sc = schema(dict(foo="string"))
>>> sc = schema(Schema(dict(foo="string")))  # no-opSchemas
Table Schemas
schema
ibis.schema(pairs=None, names=None, types=None)
Validate and return a Schema object.
Parameters
| Name | Type | Description | Default | 
|---|---|---|---|
pairs | 
SupportsSchema | None | 
List or dictionary of name, type pairs. Mutually exclusive with names and types arguments. | 
None | 
names | 
Iterable[str] | None | Field names. Mutually exclusive with pairs. | 
None | 
types | 
Iterable[str | dt.DataType] | None | 
Field types. Mutually exclusive with pairs. | 
None | 
Returns
| Type | Description | 
|---|---|
| Schema | An ibis schema | 
Examples
Schema
Schema(self, **kwargs)
An ordered mapping of str -> datatype, used to hold a Table’s schema.
Attributes
| Name | Description | 
|---|---|
| fields | A mapping of str to | 
Methods
| Name | Description | 
|---|---|
| equals | Return whether other is equal to self. | 
| from_dask | Return the equivalent ibis schema. | 
| from_numpy | Return the equivalent ibis schema. | 
| from_pandas | Return the equivalent ibis schema. | 
| from_pyarrow | Return the equivalent ibis schema. | 
| from_tuples | Construct a Schema from an iterable of pairs. | 
| name_at_position | Return the name of a schema column at position i. | 
| to_dask | Return the equivalent dask dtypes. | 
| to_numpy | Return the equivalent numpy dtypes. | 
| to_pandas | Return the equivalent pandas datatypes. | 
| to_pyarrow | Return the equivalent pyarrow schema. | 
equals
equals(other)
Return whether other is equal to self.
Parameters
| Name | Type | Description | Default | 
|---|---|---|---|
other | 
Schema | Schema to compare self to. | 
required | 
Examples
>>> import ibis
>>> first = ibis.schema({"a": "int"})
>>> second = ibis.schema({"a": "int"})
>>> assert first.equals(second)
>>> third = ibis.schema({"a": "array<int>"})
>>> assert not first.equals(third)from_dask
from_dask(dask_schema)
Return the equivalent ibis schema.
from_numpy
from_numpy(numpy_schema)
Return the equivalent ibis schema.
from_pandas
from_pandas(pandas_schema)
Return the equivalent ibis schema.
from_pyarrow
from_pyarrow(pyarrow_schema)
Return the equivalent ibis schema.
from_tuples
from_tuples(values)
Construct a Schema from an iterable of pairs.
Parameters
| Name | Type | Description | Default | 
|---|---|---|---|
values | 
Iterable[tuple[str, str | dt.DataType]] | 
An iterable of pairs of name and type. | required | 
Returns
| Type | Description | 
|---|---|
| Schema | A new schema | 
Examples
>>> import ibis
>>> ibis.Schema.from_tuples([("a", "int"), ("b", "string")])ibis.Schema {
  a  int64
  b  string
}
name_at_position
name_at_position(i)
Return the name of a schema column at position i.
Parameters
| Name | Type | Description | Default | 
|---|---|---|---|
i | 
int | The position of the column | required | 
Returns
| Type | Description | 
|---|---|
| str | The name of the column in the schema at position i. | 
Examples
>>> import ibis
>>> sch = ibis.Schema({"a": "int", "b": "string"})
>>> sch.name_at_position(0)'a'
>>> sch.name_at_position(1)'b'
to_dask
to_dask()
Return the equivalent dask dtypes.
to_numpy
to_numpy()
Return the equivalent numpy dtypes.
to_pandas
to_pandas()
Return the equivalent pandas datatypes.
to_pyarrow
to_pyarrow()
Return the equivalent pyarrow schema.