Skip to content

Adding “Rounding half to even” #17798

@wany-oh

Description

@wany-oh

Description

In python, round() usually means “Rounding half to even”, but polars Series.round()/Expr.round() do not. It should be adding an argument such as to_even to the method. At the very least, there should be a note in the documentation.

round(0.5)  # -> 0
np.round(0.5)  # -> np.float64(0.0)
pd.Series(0.5).round()[0]  # -> np.float64(0.0)

pl.Series([0.5]).round().item()  # -> 1.0

expected:

pl.Series([0.5]).round(to_even=True).item()  # -> 0.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or an improvement of an existing feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions