mutate¶
- pydiverse.transform.mutate(**kwargs: ColExpr) Pipeable[source]¶
Adds new columns to the table.
- Parameters:
kwargs – Each key is the name of a new column, and its value is the column expression defining the new column.
Examples
>>> t1 = pdt.Table( ... dict(a=[3, 1, 4, 1, 5, 9], b=[2.465, 0.22, -4.477, 10.8, -81.2, 0.0]) ... ) >>> t1 >> mutate(u=t1.a * t1.b) >> show() shape: (6, 3) ┌─────┬────────┬─────────┐ │ a ┆ b ┆ u │ │ --- ┆ --- ┆ --- │ │ i64 ┆ f64 ┆ f64 │ ╞═════╪════════╪═════════╡ │ 3 ┆ 2.465 ┆ 7.395 │ │ 1 ┆ 0.22 ┆ 0.22 │ │ 4 ┆ -4.477 ┆ -17.908 │ │ 1 ┆ 10.8 ┆ 10.8 │ │ 5 ┆ -81.2 ┆ -406.0 │ │ 9 ┆ 0.0 ┆ 0.0 │ └─────┴────────┴─────────┘