Checks

pdfexorcist.check(name: str) → Callable[[Callable[[DataFrame], Series]], Callable[[DataFrame], Series]]

Set a validation check’s display name.

pdfexorcist.total_check(col: str, total: str, parts: Sequence[str] | None = None, by: Sequence[str] = (), value: str = 'value', op: str = '==', rel_tol: float = 0.0, where: str | None = None, abs_tol: float = 0.0, name: str | None = None, missing: str = 'skip') → Callable[[DataFrame], Series]

A check that each group’s total row matches the sum of its parts.

Parameters:
  • col – Column naming totals and parts (e.g. “Sex”, “State”).

  • total – The col value of the total row (e.g. “T”).

  • parts – Col values that add up to it; default every other value in the group.

  • by – Columns identifying one group.

  • value – The numeric column.

  • op – “==”, “>=” (total may exceed its parts) or “<=”.

  • rel_tol – Allowed relative gap, e.g. 0.02.

  • where – DataFrame.query string limiting the rows checked.

  • abs_tol – Allowed absolute gap, e.g. 0.05 for rounded decimals.

  • name – What validate() writes into failed; default generated.

  • missing – “skip” leaves a group missing its total or a part unjudged; “fail” fails a group whose total is present but a part is missing.

pdfexorcist.validate(df: DataFrame, checks: Iterable[Callable[[DataFrame], Series]]) → DataFrame

Add semicolon-separated failed check names to each row.