Round
Description
Round underlying floating point data by decimals
digits.
Usage
<Expr>$round(decimals)
Arguments
decimals
|
Number of decimals to round by. |
Value
Expr
Examples
library("polars")
pl$DataFrame(a = c(0.33, 0.5, 1.02, 1.5, NaN, NA, Inf, -Inf))$with_columns(
round = pl$col("a")$round(1)
)
#> shape: (8, 2)
#> ┌──────┬───────┐
#> │ a ┆ round │
#> │ --- ┆ --- │
#> │ f64 ┆ f64 │
#> ╞══════╪═══════╡
#> │ 0.33 ┆ 0.3 │
#> │ 0.5 ┆ 0.5 │
#> │ 1.02 ┆ 1.0 │
#> │ 1.5 ┆ 1.5 │
#> │ NaN ┆ NaN │
#> │ null ┆ null │
#> │ inf ┆ inf │
#> │ -inf ┆ -inf │
#> └──────┴───────┘