Schema
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
cleardef clear(*args = (), **kwargs = {})
Remove all entries, leaving an empty schema.
Parameters:
*args**kwargscopydef copy(*args = (), **kwargs = {})
Return a shallow copy of this schema.
Parameters:
*args**kwargsfromkeysdef fromkeys(iterable, value = None)
Build a schema from the given names, all with the same data type.
Parameters:
iterablevaluegetdef get(key, default = None)
Return the data type for key, or default if absent.
Parameters:
keydefaultExample:
tf.schema.get("a")
A default keeps the lookup total when the column may be absent:
tf.schema.get("missing", String)
itemsdef items(*args = (), **kwargs = {})
Return the (name, data type) pairs, in column order.
Parameters:
*args**kwargsExample:
[(name, dtype) for name, dtype in tf.schema.items()]
keysdef keys(*args = (), **kwargs = {})
Return the column names, in column order.
Parameters:
*args**kwargsExample:
list(tf.schema.keys())
move_to_enddef move_to_end(key, last = True)
Move column key to the end (or the start when last is False).
Parameters:
keylastpopdef pop(*args = (), **kwargs = {})
Remove column key and return its data type.
Parameters:
*args**kwargspopitemdef popitem(last = True)
Remove and return the last (or first) (name, data type) pair.
Parameters:
lastsetdefaultdef setdefault(key, default = None)
Return key's data type, inserting default if it is absent.
Parameters:
keydefaultupdatedef update(*args = (), **kwargs = {})
Update this schema in place from another mapping of columns.
Parameters:
*args**kwargsvaluesdef values(*args = (), **kwargs = {})
Return the data types, in column order.
Parameters:
*args**kwargsExample:
list(tf.schema.values())
namesdef names() -> list[str]
Return the column names, in column order.
Example:
tf.schema.names()
dtypesdef dtypes() -> list[DataType]
Return the column data types, in column order.
Example:
tf.schema.dtypes()
to_arrowdef to_arrow(*, compat_level: None = None) -> Any
Return this schema as a PyArrow schema.
Parameters:
compat_levelNoneExample:
tf.schema.to_arrow()
to_framedef to_frame() -> TableFrame
Return an empty TableFrame having exactly this schema.
Example:
tf.schema.to_frame()
lendef len() -> int
Return the number of columns.
Example:
tf.schema.len()
to_pythondef to_python() -> dict[str, type]
Return a dict mapping each column name to its Python type.
Example:
tf.schema.to_python()["a"] # <class 'int'>
contains_dtype