Skip to main content
GuideServerConfigure and deploy Tabsdata servers on your machine.TutorialsConfigure data integration workflows within a running Tabsdata server.Advanced TutorialsBuild end-to-end workflows between two specific systems.API ReferenceCLI ReferenceRelease Notes
Version: 2.0.0

Schema

class
class Schema

Categories: attributes

Ordered mapping of column name to data type.

Returned by TableFrame.schema. Iterates in column order and supports mapping access (schema["col"], "col" in schema, len(schema)) plus the query helpers below.

Examples

tf.schema["a"]
tf.schema.names()

Methods

method
clear
def clear(*args = (), **kwargs = {})

Remove all entries, leaving an empty schema.

Parameters:

parameter
*args

parameter
**kwargs

method
copy
def copy(*args = (), **kwargs = {})

Return a shallow copy of this schema.

Parameters:

parameter
*args

parameter
**kwargs

method
fromkeys
def fromkeys(iterable, value = None)

Build a schema from the given names, all with the same data type.

Parameters:

parameter
iterable

parameter
value

method
get
def get(key, default = None)

Return the data type for key, or default if absent.

Parameters:

parameter
key

parameter
default

Example:

tf.schema.get("a")

A default keeps the lookup total when the column may be absent:

tf.schema.get("missing", String)

method
items
def items(*args = (), **kwargs = {})

Return the (name, data type) pairs, in column order.

Parameters:

parameter
*args

parameter
**kwargs

Example:

[(name, dtype) for name, dtype in tf.schema.items()]

method
keys
def keys(*args = (), **kwargs = {})

Return the column names, in column order.

Parameters:

parameter
*args

parameter
**kwargs

Example:

list(tf.schema.keys())

method
move_to_end
def move_to_end(key, last = True)

Move column key to the end (or the start when last is False).

Parameters:

parameter
key

parameter
last

method
pop
def pop(*args = (), **kwargs = {})

Remove column key and return its data type.

Parameters:

parameter
*args

parameter
**kwargs

method
popitem
def popitem(last = True)

Remove and return the last (or first) (name, data type) pair.

Parameters:

parameter
last

method
setdefault
def setdefault(key, default = None)

Return key's data type, inserting default if it is absent.

Parameters:

parameter
key

parameter
default

method
update
def update(*args = (), **kwargs = {})

Update this schema in place from another mapping of columns.

Parameters:

parameter
*args

parameter
**kwargs

method
values
def values(*args = (), **kwargs = {})

Return the data types, in column order.

Parameters:

parameter
*args

parameter
**kwargs

Example:

list(tf.schema.values())

method
names
def names() -> list[str]

Return the column names, in column order.

Example:

tf.schema.names()

method
dtypes
def dtypes() -> list[DataType]

Return the column data types, in column order.

Example:

tf.schema.dtypes()

method
to_arrow
def to_arrow(*, compat_level: None = None) -> Any

Return this schema as a PyArrow schema.

Parameters:

parameter
compat_levelNone

Example:

tf.schema.to_arrow()

method
to_frame
def to_frame() -> TableFrame

Return an empty TableFrame having exactly this schema.

Example:

tf.schema.to_frame()

method
len
def len() -> int

Return the number of columns.

Example:

tf.schema.len()

method
to_python
def to_python() -> dict[str, type]

Return a dict mapping each column name to its Python type.

Example:

tf.schema.to_python()["a"] # <class 'int'>

method
contains_dtype
def contains_dtype(dtype: DataType, *, recursive: bool) -> bool

Return whether any column has the given data type.

Parameters:

parameter

Data type to look for.

parameter
recursivebool

Also match the type nested inside List / Struct / Array columns.

Example:

tf.schema.contains_dtype(String, recursive=False)

recursive=True also looks inside List / Struct / Array columns:

tf.schema.contains_dtype(String, recursive=True)