Skip to main content
Version: 1.7.1

TableFrame.with_columns

def with_columns(
*exprs: td_IntoExpr | Iterable[td_IntoExpr],
**named_exprs: td_IntoExpr,
) -> TableFrame

Categories: projection

Add columns to the TableFrame.

Parameters

parameter
exprs

Columns or expressions to add.

parameter
named_exprs

Named expressions to add.

Examples

>>> import tabsdata as td
>>>
>>> tf: td.TableFrame ...
>>>
┌──────┬──────┐
│ x ┆ y │
------
│ f64 ┆ f64 │
╞══════╪══════╡
1.02.0
2.02.0
10.010.0
4.010.0
5.0 ┆ null │
│ null ┆ null │
└──────┴──────┘
>>>
>>> tf.with_columns(td.col("x").mul(td.col("y")).alias("z"))
>>>
┌──────┬──────┬──────┐
│ x ┆ y ┆ z │
---------
│ f64 ┆ f64 ┆ f64 │
╞══════╪══════╪══════╡
1.02.02.0
2.02.04.0
│ NaN ┆ NaN ┆ NaN │
4.0 ┆ NaN ┆ NaN │
5.0 ┆ null ┆ null │
│ null ┆ null ┆ null │
└──────┴──────┴──────┘