Rename column names of a DataFrame
Description
Rename column names of a DataFrame
Usage
<DataFrame>$rename(...)
Arguments
…
|
One of the following:
|
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
DataFrame
Examples
library("polars")
df = pl$DataFrame(
foo = 1:3,
bar = 6:8,
ham = letters[1:3]
)
df$rename(foo = "apple")
#> shape: (3, 3)
#> ┌───────┬─────┬─────┐
#> │ apple ┆ bar ┆ ham │
#> │ --- ┆ --- ┆ --- │
#> │ i32 ┆ i32 ┆ str │
#> ╞═══════╪═════╪═════╡
#> │ 1 ┆ 6 ┆ a │
#> │ 2 ┆ 7 ┆ b │
#> │ 3 ┆ 8 ┆ c │
#> └───────┴─────┴─────┘
#> shape: (3, 3)
#> ┌─────┬─────┬─────┐
#> │ coo ┆ car ┆ cam │
#> │ --- ┆ --- ┆ --- │
#> │ i32 ┆ i32 ┆ str │
#> ╞═════╪═════╪═════╡
#> │ 1 ┆ 6 ┆ a │
#> │ 2 ┆ 7 ┆ b │
#> │ 3 ┆ 8 ┆ c │
#> └─────┴─────┴─────┘