Skip to content

convert_types raises TypeError on pd.NA labels #1844

@themavik

Description

@themavik

When a categorical column contains pd.NA values, running a preset like DataSummaryPreset crashes with a pydantic ValidationError.

Root cause: convert_types() calls np.isnan(val) without a type guard. np.isnan(pd.NA) raises TypeError because pd.NA doesn't support the isnan protocol.

Repro from #1616:

import pandas as pd
from evidently import DataDefinition, Dataset
from evidently.presets import DataSummaryPreset, Report

df = pd.DataFrame({"a": pd.Series(["x", "y", "z", pd.NA], dtype="str")})
definition = DataDefinition(categorical_columns=["a"])
report = Report([DataSummaryPreset()])
data = Dataset.from_pandas(df, definition)
report.run(current_data=data)

Traceback ends at metric_types.py in convert_types — np.isnan(val) where val is pd.NA.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions