Skip to content
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

Nullability for pl.Float64 in pl.DataFrame fails #1626

Closed
2 tasks done
MariusMerkleQC opened this issue May 8, 2024 · 1 comment · Fixed by #1627
Closed
2 tasks done

Nullability for pl.Float64 in pl.DataFrame fails #1626

MariusMerkleQC opened this issue May 8, 2024 · 1 comment · Fixed by #1627
Labels
bug Something isn't working

Comments

@MariusMerkleQC
Copy link
Contributor

Describe the bug
The nullability constraint is not enforced in pl.DataFrame when the underlying data type is pl.Float64. When I provide a pl.DataFrame with a float column that contains None, it passes.

  • I have checked that this issue has not already been reported.
  • I have confirmed this bug exists on the latest version of pandera.

Code Sample, a copy-pastable example

import polars as pl
import pandera.polars as pa


class Schema(pa.DataFrameModel):
    col: float = pa.Field(nullable=False)


df = pl.DataFrame(data={"col": [1.0, 2.5, None]}, schema={"col": pl.Float64})

Schema.validate(df)

Expected behavior

The validation should vail as the column col contains a None value, but the schema requires it to be non-nullable.

Desktop (please complete the following information):

  • OS: MacOS
  • Browser: Chrome

Additional context

The nullability constraint is correctly enforced if the underlying data type is int or str.
For float, the nullability constraint correctly detects NULL values in the form of np.nan.

@cosmicBboy
Copy link
Collaborator

great catch @MariusMerkleQC ! #1627 should fix this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants