-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inconsistent Decimal to float type casting in pl.from_dicts() & pl.DataFrame() #8641
Comments
I observed a similar issue when constructing a
The decimal scale seems to get lost during the conversion to float. I'm not sure how complicated it would be to fix this issue, but maybe it would be possible to raise an exception in this case for now. |
I'm also experiencing very inconsistent behavior with Just changing the flag "orient" give different processing of import polars as pl
from decimal import Decimal
pl.DataFrame([[Decimal("12.45")]], orient="row") which gives:
but pl.DataFrame([[Decimal("12.45")]], orient="col") gives
So it seems conversion to float goes wrong. Would be great to have it fixed since it leads to pretty severely wrong results. I'm on linux with polars 0.18.15 |
@scur-iolus: I notice you checked the box that says "I have confirmed this bug exists on the latest version of Polars.", but your installed version is @ronaldrichter: Looks like you're also on an older version; please install the latest release and you'll see the correct result. @lmmentel: Your scaling issue was essentially the same as the others and was also fixed, but the dtype difference observed when initialising with |
@alexander-beedie you probably did not notice that I opened this issue 5 months ago, at that time 0.17.11 was indeed the latest version 😉 But I wasn't aware it had been fixed, thank you! |
Oh! Quite right, my bad... odd that it showed up on the first page of the Issues list - that threw me off; I must have accidentally sorted or filtered it by something 😅 |
Sure thing, I can verify that with 0.19.3 the decimals are parsed correctly but still being converted to either Thanks for your help o this 👍 |
Polars version checks
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of Polars.
Issue description
The 2 examples provided below should be self-explicit and easier to read than a description of the issue.
The problem is the same whether the conversion (
Decimal
tofloat
) is explicit or implicit, cf. examples below.I am aware that the support for Decimal is an "experimental work-in-progress feature" (see #4104).
Reproducible example
Expected behavior
In both examples, I was expecting to get something like:
But I got:
The exponent-part of this value was 1, it became 10.
Installed versions
Polars 0.17.11
The text was updated successfully, but these errors were encountered: