tabsdata.tableframe.lazyframe.frame.TableFrame.with_columns#

TableFrame.with_columns(*exprs: td_expr.IntoExpr | Iterable[td_expr.IntoExpr], **named_exprs: td_expr.IntoExpr) TableFrame[source]#

Add columns to the TableFrame.

Parameters:
  • exprs – Columns or expressions to add.

  • named_exprs – Named expressions to add.

Example:

>>> import tabsdata as td
>>>
>>> tf: td.TableFrame ...
>>>
┌──────┬──────┐
│ x    ┆ y    │
│ ---  ┆ ---  │
│ f64  ┆ f64  │
╞══════╪══════╡
│ 1.0  ┆ 2.0  │
│ 2.0  ┆ 2.0  │
│ 10.0 ┆ 10.0 │
│ 4.0  ┆ 10.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.0  ┆ 2.0  ┆ 2.0  │
│ 2.0  ┆ 2.0  ┆ 4.0  │
│ NaN  ┆ NaN  ┆ NaN  │
│ 4.0  ┆ NaN  ┆ NaN  │
│ 5.0  ┆ null ┆ null │
│ null ┆ null ┆ null │
└──────┴──────┴──────┘