Skip to content

Compute absolute values

Description

Compute absolute values

Usage

<Expr>$abs()

Value

A polars expression

Examples

library("polars")

df <- pl$DataFrame(a = -1:2)
df$with_columns(abs = pl$col("a")$abs())
#> shape: (4, 2)
#> ┌─────┬─────┐
#> │ a   ┆ abs │
#> │ --- ┆ --- │
#> │ i32 ┆ i32 │
#> ╞═════╪═════╡
#> │ -1  ┆ 1   │
#> │ 0   ┆ 0   │
#> │ 1   ┆ 1   │
#> │ 2   ┆ 2   │
#> └─────┴─────┘