Skip to content

Add a suffix to a column name

Source code

Description

Add a suffix to a column name

Usage

<Expr>$name$suffix(suffix)

Arguments

suffix Suffix to be added to column name(s)

Value

Expr

See Also

$prefix() to add a prefix

Examples

library("polars")

dat = pl$DataFrame(mtcars)

dat$select(
  pl$col("mpg"),
  pl$col("mpg")$name$suffix("_foo"),
  pl$col("cyl", "drat")$name$suffix("_bar")
)
#> shape: (32, 4)
#> ┌──────┬─────────┬─────────┬──────────┐
#> │ mpg  ┆ mpg_foo ┆ cyl_bar ┆ drat_bar │
#> │ ---  ┆ ---     ┆ ---     ┆ ---      │
#> │ f64  ┆ f64     ┆ f64     ┆ f64      │
#> ╞══════╪═════════╪═════════╪══════════╡
#> │ 21.0 ┆ 21.0    ┆ 6.0     ┆ 3.9      │
#> │ 21.0 ┆ 21.0    ┆ 6.0     ┆ 3.9      │
#> │ 22.8 ┆ 22.8    ┆ 4.0     ┆ 3.85     │
#> │ 21.4 ┆ 21.4    ┆ 6.0     ┆ 3.08     │
#> │ 18.7 ┆ 18.7    ┆ 8.0     ┆ 3.15     │
#> │ …    ┆ …       ┆ …       ┆ …        │
#> │ 30.4 ┆ 30.4    ┆ 4.0     ┆ 3.77     │
#> │ 15.8 ┆ 15.8    ┆ 8.0     ┆ 4.22     │
#> │ 19.7 ┆ 19.7    ┆ 6.0     ┆ 3.62     │
#> │ 15.0 ┆ 15.0    ┆ 8.0     ┆ 3.54     │
#> │ 21.4 ┆ 21.4    ┆ 4.0     ┆ 4.11     │
#> └──────┴─────────┴─────────┴──────────┘