You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(polars): keep integers exact when a polars column holds nulls (#467)
pl.DataFrame.to_pandas() renders an integer column that has nulls as float64,
because a NumPy integer array cannot hold one. That silently rounds every
value a float64 cannot represent: 2**53 + 1 came back as 2**53, and a UInt64
beyond 2**63 lost far more.
This is not limited to engine="polars". Every public entry point reads a
polars source through adapters.polars.to_pandas(), so fd.clean(pl_df) on the
DEFAULT engine already returned the rounded value.
Integer columns that hold nulls are now rebuilt from the raw integers plus a
null mask, giving the pandas nullable dtype of the same width (Int64, UInt64,
Int32, ...) — lossless, and what the same data already looked like when passed
in as pandas. Columns without nulls round-trip exactly today and are untouched.
The native polars engine converts its result through the same adapter instead
of calling frame.to_pandas() directly.
Default-output change: a polars input whose integer column holds nulls now
cleans as a nullable integer column instead of float64.
Closes#444
Co-authored-by: Kevin Costner <kiran.gangalakunta@gmail.com>
0 commit comments