Open antonioalegria opened 2 months ago
Hi @antonioalegria, this is the intended behavior. Optional
marks a column as not required to be in the dataframe (see docs). You still have to mark it as nullable=True
specifically in the Field
, these are two different behaviors.
I see. Then str | None should be equivalent to nullable=True, no? In any case, if Optional means the column can be missing, it would mean it would also be nullable, no?
I have a workaround that marks all my Optional columns as nullable as well, dynamically but am wondering if there is a more natural (i.e. least unexpected) behavior.
Thanks!
Describe the bug A clear and concise description of what the bug is.
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
The dataframe should've been validated.
Desktop (please complete the following information):
OS: macOS 14.6.1 Python 3.12.4 polars-lts-cpu 1.6.0 pandera 0.20.3
Screenshots
If applicable, add screenshots to help explain your problem.
Additional context
Add any other context about the problem here.