pandera pandas dtype mismatch in CI
pandera rejected a column because its pandas dtype does not match the schema. In CI this often stems from a different pandas version inferring types differently, or nulls promoting an int column to float or object.
What this error means
pandera raises a SchemaError about the series type, for example expecting int64 but getting object or float64, that reproduces in CI but not always locally.
pandera.errors.SchemaError: expected series 'quantity' to have type int64,
got float64Common causes
Nulls promoted the column type
A single null in an integer column makes pandas store it as float64 (or object), which fails a strict int64 schema.
A different pandas version in CI
CI resolved a pandas version whose type inference differs from local, so the same data yields a different dtype.
How to fix it
Use a nullable dtype or coerce
- Declare a nullable integer dtype so nulls do not force a float.
- Or enable
coerce=Trueto cast compatible types. - Pin pandas so inference is consistent between local and CI.
pa.Column(pd.Int64Dtype(), nullable=True) # nullable integer, not float64Pin the pandas version
Lock pandas so CI and local infer dtypes identically, removing environment-specific failures.
python -m pip install "pandas==2.2.*"How to prevent it
- Use nullable dtypes for integer columns that can be null.
- Pin pandas so type inference is reproducible.
- Enable coercion for benign type differences.