Pointblank Validation | |||||||||||||
2025-10-09|20:53:24 Polars |
|||||||||||||
STEP | COLUMNS | VALUES | TBL | EVAL | UNITS | PASS | FAIL | W | E | C | EXT | ||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
#4CA64C | 1 |
col_vals_between()
|
✓ | 1 | 1 1.00 |
0 0.00 |
— | — | — | — | |||
#4CA64C | 2 |
col_vals_eq()
|
✓ | 13 | 13 1.00 |
0 0.00 |
— | — | — | — | |||
2025-10-09 20:53:24 UTC< 1 s2025-10-09 20:53:24 UTC |
Mutate the Table in a Validation Step
For far more specialized validations, modify the table with the pre=
argument before checking it.
import pointblank as pb
import polars as pl
import narwhals as nw
# Define preprocessing functions
def get_median_a(df):
"""Use a Polars expression to aggregate column `a`."""
return df.select(pl.median("a"))
def add_b_length_column(df):
"""Use Narwhals to add a string length column `b_len`."""
return (
nw.from_native(df)=nw.col("b").str.len_chars())
.with_columns(b_len
)
= (
validation
pb.Validate(=pb.load_dataset(dataset="small_table", tbl_type="polars")
data
)
.col_vals_between(="a",
columns=3, right=6,
left=get_median_a
pre
)
.col_vals_eq(="b_len",
columns=9,
value=add_b_length_column
pre
)
.interrogate()
)
validation
Preview of Input Table
PolarsRows13Columns8 |
||||||||