Select and modify columns of a LazyFrame
Description
Similar to dplyr::mutate()
. However, it discards
unmentioned columns (like .()
in data.table
).
Usage
<LazyFrame>$select(...)
Arguments
…
|
Columns to keep. Those can be expressions (e.g
pl$col(“a”) ), column names (e.g “a” ), or list
containing expressions or column names (e.g
list(pl$col(“a”)) ).
|
Value
A LazyFrame
Examples
library("polars")
as_polars_lf(iris)$select(
pl$col("Sepal.Length")$abs()$alias("abs_SL"),
(pl$col("Sepal.Length") + 2)$alias("add_2_SL")
)
#> polars LazyFrame
#> $explain(): Show the optimized query plan.
#>
#> Naive plan:
#> SELECT [col("Sepal.Length").abs().alias("abs_SL"), [(col("Sepal.Length")) + (2.0)].alias("add_2_SL")] FROM
#> DF ["Sepal.Length", "Sepal.Width", "Petal.Length", "Petal.Width"]; PROJECT */5 COLUMNS; SELECTION: None