Method: Polars::Expr#round

Defined in:
lib/polars/expr.rb

#round(decimals = 0) ⇒ Expr

Round underlying floating point data by decimals digits.

Examples:

df = Polars::DataFrame.new({"a" => [0.33, 0.52, 1.02, 1.17]})
df.select(Polars.col("a").round(1))
# =>
# shape: (4, 1)
# ┌─────┐
# │ a   │
# │ --- │
# │ f64 │
# ╞═════╡
# │ 0.3 │
# │ 0.5 │
# │ 1.0 │
# │ 1.2 │
# └─────┘

Parameters:

  • decimals (Integer) (defaults to: 0)

    Number of decimals to round by.

Returns:

[View source]

1179
1180
1181
# File 'lib/polars/expr.rb', line 1179

def round(decimals = 0)
  _from_rbexpr(_rbexpr.round(decimals))
end