pola-rs / polars

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

Add `precision` parameter to `.cut()` and `.qcut()` #14374

Open ryantaylor406 opened 7 months ago

ryantaylor406 commented 7 months ago

Description

Often times I create plots where I need to discretize data via cut() or qcut(). The functions work appropriately, however the bin labels spit out 10+ decimal places which looks less than ideal on a plot axis (and in dataframes as well). Pandas has a parameter precision in their cut and qcut functions that sets the precision at which to store and display the bin labels to address this issue.

This would be amazing if we could have this parameter in polars!

markxwang commented 7 months ago

As a workaround, you can always do pl.col("xx").round(precision).qcut()