Rename column names
Description
Rename column names
Usage
<LazyFrame>$rename(..., .strict = TRUE)
Arguments
…
|
\<dynamic-dots \> Either a function that takes a character
vector as input and returns a character vector as output, or named
values where names are old column names and values are the new ones.
|
.strict
|
Validate that all column names exist in the current schema, and throw an
error if any do not. (Note that this parameter is a no-op when passing a
function to … ).
|
Details
If existing names are swapped (e.g. ‘A’ points to ‘B’ and ‘B’ points to ‘A’), polars will block projection and predicate pushdowns at this node.
Value
A polars LazyFrame
Examples
library("polars")
lf <- pl$LazyFrame(
foo = 1:3,
bar = 6:8,
ham = letters[1:3]
)
lf$rename(foo = "apple")$collect()
#> shape: (3, 3)
#> ┌───────┬─────┬─────┐
#> │ apple ┆ bar ┆ ham │
#> │ --- ┆ --- ┆ --- │
#> │ i32 ┆ i32 ┆ str │
#> ╞═══════╪═════╪═════╡
#> │ 1 ┆ 6 ┆ a │
#> │ 2 ┆ 7 ┆ b │
#> │ 3 ┆ 8 ┆ c │
#> └───────┴─────┴─────┘