Skip to content

Commit 9c674bc

Browse files
author
Sylvain MARIE
committed
check_nullable does not uselessly compute isna() anymore in pandas backend. Fixed #1533
1 parent 9c484a9 commit 9c674bc

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

pandera/backends/pandas/array.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,16 @@ def check_name(self, check_obj: pd.Series, schema) -> CoreCheckResult:
194194

195195
@validate_scope(scope=ValidationScope.SCHEMA)
196196
def check_nullable(self, check_obj: pd.Series, schema) -> CoreCheckResult:
197+
if schema.nullable:
198+
# Avoid to compute anything for perf reasons. GH#1533
199+
return CoreCheckResult(
200+
passed=True,
201+
check="not_nullable",
202+
)
203+
204+
# Check actual column contents
197205
isna = check_obj.isna()
198-
passed = schema.nullable or not isna.any()
206+
passed = not isna.any()
199207
return CoreCheckResult(
200208
passed=cast(bool, passed),
201209
check="not_nullable",

0 commit comments

Comments
 (0)