diff --git a/pandera/backends/pandas/array.py b/pandera/backends/pandas/array.py index cea755b64..7025061a4 100644 --- a/pandera/backends/pandas/array.py +++ b/pandera/backends/pandas/array.py @@ -203,7 +203,12 @@ def check_nullable(self, check_obj: pd.Series, schema) -> CoreCheckResult: # Check actual column contents isna = check_obj.isna() - passed = not isna.any() + passed = schema.nullable or not isna.any() + failure_cases = ( + reshape_failure_cases(check_obj[isna], ignore_na=False) + if not passed + else None + ) return CoreCheckResult( passed=cast(bool, passed), check="not_nullable", @@ -212,9 +217,7 @@ def check_nullable(self, check_obj: pd.Series, schema) -> CoreCheckResult: f"non-nullable series '{check_obj.name}' contains " f"null values:\n{check_obj[isna]}" ), - failure_cases=reshape_failure_cases( - check_obj[isna], ignore_na=False - ), + failure_cases=failure_cases, ) @validate_scope(scope=ValidationScope.DATA)