-
-
Notifications
You must be signed in to change notification settings - Fork 294
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
Decimal validation not fully supported #1689
Comments
Can you try using the polars native Decimal dtype? https://docs.pola.rs/api/python/stable/reference/api/polars.datatypes.Decimal.html#polars.datatypes.Decimal |
@cosmicBboy In fact if I cast a column to polars Decimal, it actually results in a python decimal.Decimal from decimal import Decimal
import polars as pl
df = pl.DataFrame({'a': [Decimal('1')]})
cast = df.select(pl.col('a').cast(pl.Decimal()))
cast['a'][0]
>> Decimal('1')
type(cast['a'][0])
>> decimal.Decimal Maybe I've missed a step here though! |
So in pandera, element wise checks use And it looks like it currently does not support mapping a function over decimal dtype: (
pl.LazyFrame({"a": [Decimal(1)]})
.with_columns(
pl.col("a").map_elements(lambda x: x)
).collect()
) error:
You can raise this issue in the polars repo. For now, I'd recommend using the vectorized checks that operate on the lazyframe itself: https://pandera.readthedocs.io/en/latest/polars.html#column-level-checks |
Ok cool thank you So basically you're saying it'll fail for any DataFrame-level checks? |
yeah, it'll fail for any element-wise check that operates on decimal types. |
Describe the bug
Validation of Decimal type not fully supported.
I have run into a number of issues when trying to use Decimals in pandera (e.g. failing to encode JSON when rendering SchemaErrors) but this one I couldn't avoid.
Note: Please read this guide detailing how to provide the necessary information for us to reproduce your bug.
Code Sample, a copy-pastable example
Expected behavior
A SchemaError / SchemaErrors
Desktop (please complete the following information):
Additional context
Full traceback:
The text was updated successfully, but these errors were encountered: