pandera.decisions.Holds¶

pandera.decisions.Holds(instructions, *, context=None, min_probability=0.5, provider=None, name=None, **check_kwargs)[source]¶

Check that a statement holds of each row, as judged by a model.

schema = pa.DataFrameSchema(
    {
        "name": pa.Column(str),
        "category": pa.Column(str),
        "description": pa.Column(str),
    },
    checks=decisions.Holds(
        "The description is a coherent description of a product "
        "belonging to the stated category",
        context=["name", "category", "description"],
        min_probability=0.85,
    ),
)

Used as a column check, the column’s own value is what gets judged. Used as a dataframe check with context, those columns are sent instead, which is the only way to judge a value relative to another column.

Inside a @pa.dataframe_check method, use holds() instead – that wants the boolean Series, not a Check.

Parameters:
  • instructions (str) – the statement to judge.

  • context (UnionType[Sequence[str], None]) – columns to send. Requires a dataframe-level check.

  • min_probability (float) – the probability at or above which the statement is taken to hold.

  • provider (Any) – overrides the configured provider.

  • check_kwargs (Any) – everything Check accepts.

Return type:

Check