polars
polars copied to clipboard
Support `round` for Decimal type
Description
Currently the decimal type does not suport round
. Imo this makes sense to implement for many financial calculation where you require the precision of a decimal but in the end need to round to some fixed value.
from decimal import Decimal as D
import polars as pl
pl.DataFrame({"x": [D("0.246")]}).with_columns(r=pl.col("x").round(decimals=2))
# InvalidOperationError: `round` operation not supported for dtype `decimal[*,3]`
Currently I can only truncate the decimal for example with .cast(pl.Decimal(scale=2))
but this ofc does NOT round.