tabsdata.tableframe.functions.col
Col | This class is used to create TableFrame column expressions. |
Column | Represents a single column definition in a :class:TableFrame. |
Col
class Col(*args, **kwargs)
This class is used to create TableFrame column expressions.
An instance of this class is available as col. It can be called like a function
(e.g., td.col("name")).
For more information, refer to the __call__ method documentation.
This helper class provides an alternative way to create column expressions using
attribute lookup.
For instance, col.name is equivalent to col("name"). Refer to
:func:__getattr__ method.
Example:
>>> import tabsdata as td
>>>
>>> tf: td.TableFrame ...
>>>
>>> tf = tf.with_columns(full_name=(td.col("last_name") + ", " + >>> td.col("first_name"))
Column
class Column(name: str | None = None, dtype: td_DataType = String)
Represents a single column definition in a :class:TableFrame.
A Column defines both the name and the data type of a column,
along with other relevant metadata in the future. This abstraction provides
a consistent way to declare and validate schema definitions for TableFrame
objects.
Attributes:
namestr | NoneThe name of the column, or None if no name was provided.
dtypetd_DataTypeThe declared data type of the column.
Example:
Create a column with a name and type:
>>> import tabsdata as td
>>> Column("customer_id", td.Int64)
<Column name='customer_id' dtype=Int64>
Use columns to define a TableFrame schema:
>>> import tabsdata as td
>>> schema = [
... Column("customer_id", td.Int64),
... Column("signup_date", td.Datetime),
... ]
>>> for column in schema:
... print(column.name, column.dtype)
customer_id Int64
signup_date Datetime