import pointblank as pb
import polars as pl
amount_standard = pb.Standard(
name="amount-columns",
steps=[
pb.Step("col_vals_not_null", columns=pb.contains("amount")),
pb.Step("col_vals_ge", columns=pb.contains("amount"), value=0),
],
)
refunds = pl.DataFrame({"refund_id": [1, 2, 3], "refund_amount": [15.0, 0.0, -3.5]})
amount_standard.validate(refunds, tbl_name="refunds")Standard.validate()
Check a single table against the standard.
Usage
Standard.validate(
data,
tbl_name=None,
)This compiles the standard for the table (with to_validate()) and interrogates it. It’s what apply() does for each table it finds, so it’s a quick way to try a standard on one table, or to check a table that’s not part of a source.
Parameters
data: IntoDataFrame-
The table to validate. Any table type that Validate takes can be used.
tbl_name: str | None = None-
The name of the table, for the validation’s
tbl_name=.
Returns
Validate- An interrogated Validate object.
Examples
Let’s try a standard for amount columns on a table of refunds before applying it to a whole warehouse.
The negative refund fails the second step. The validation is an ordinary interrogated Validate object, so a check like all_passed() works on it as well.