Pointblank Validation | |||||||||||||
2025-01-20|18:17:30 Polars |
|||||||||||||
STEP | COLUMNS | VALUES | TBL | EVAL | UNITS | PASS | FAIL | W | S | N | EXT | ||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
#4CA64C | 1 |
|
✓ | 1 | 1 1.00 |
0 0.00 |
— | — | — | — | |||
2025-01-20 18:17:30 UTC< 1 s2025-01-20 18:17:30 UTC |
Check the Schema of a Table
The schema of a table can be flexibly defined with Schema
and verified with col_schema_match()
.
import pointblank as pb
import polars as pl
= pl.DataFrame(
tbl
{"a": ["apple", "banana", "cherry", "date"],
"b": [1, 6, 3, 5],
"c": [1.1, 2.2, 3.3, 4.4],
}
)
# Use the Schema class to define the column schema as loosely or rigorously as required
= pb.Schema(
schema =[
columns"a", "String"), # Column 'a' has dtype 'String'
("b", ["Int", "Int64"]), # Column 'b' has dtype 'Int' or 'Int64'
("c", ) # Column 'c' follows 'b' but we don't specify a dtype here
(
]
)
# Use the `col_schema_match()` validation method to perform the schema check
= (
validation =tbl)
pb.Validate(data=schema)
.col_schema_match(schema
.interrogate()
)
validation