pola-rs / polars

Dataframes powered by a multithreaded, vectorized query engine, written in Rust
https://docs.pola.rs
Other
26.63k stars 1.63k forks source link

docs(python): Explain how Polars floor division differs from Python #16054

Closed bertiewooster closed 1 week ago

bertiewooster commented 1 week ago

Adds an example explaining how Polars does floating-point division, then does the flooring operation. Fixes #14614.

@orlp is this explanation good?

Polars instead first does the floating-point division, resulting in a floating-point value of 60.0, and then performs the flooring operation using floor

The goal is to explain why Polars' division operation of 6.0 / 0.1 does not also, like Python, give 59.999___ (and then floor it to 59.0) considering that 0.1 is represented in the computer as slightly greater than 0.1.

bertiewooster commented 1 week ago

Thanks for reviewing and merging! For future reference, the changes are live in the dev docs, and will appear in the default stable docs upon the next release.