Skip to content

Commit 7745edb

Browse files
authored
Merge pull request #24 from UBC-DSCI/pointblank-py
pointblank python
2 parents d749550 + ab733a4 commit 7745edb

File tree

3 files changed

+64
-0
lines changed

3 files changed

+64
-0
lines changed

book/_quarto.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ book:
4040
- lectures/131-data_validation-r-pointblank.qmd
4141
- lectures/135-data_validation-python-pandera.qmd
4242
- lectures/136-data_validation-python-deepchecks.qmd
43+
- lectures/137-data_validation-python-pointblank.qmd
4344
- part: parts/automation.qmd
4445
chapters:
4546
- lectures/150-scripts.qmd
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
---
2+
title: "Python Data Validation: pointblank"
3+
---
4+
5+
This chapter goes through the `{pointblank}` R package that has been ported into Python:
6+
<https://posit-dev.github.io/pointblank/>
7+
8+
9+
```{python}
10+
import pointblank as pb
11+
12+
small_table = pb.load_dataset(dataset="small_table")
13+
small_table
14+
```
15+
16+
## Validation rules
17+
18+
19+
```{python}
20+
pb.Validate(small_table).col_vals_lt(columns="a", value=10)
21+
```
22+
23+
24+
```{python}
25+
pb.Validate(small_table).col_vals_lt(columns="a", value=5)
26+
```
27+
28+
29+
```{python}
30+
validation = (
31+
pb.Validate(small_table)
32+
.col_vals_between(columns="d", left=0, right=5000)
33+
.col_vals_le(columns="c", value=5)
34+
.col_exists(columns=["date", "date_time"])
35+
.interrogate()
36+
)
37+
38+
validation
39+
```
40+
41+
## Post-interrogation
42+
43+
44+
```{python}
45+
validation = (
46+
pb.Validate(small_table)
47+
.col_vals_between(columns="d", left=0, right=5000)
48+
.col_vals_le(columns="c", value=5)
49+
.col_exists(columns=["date", "date_time"])
50+
.interrogate()
51+
)
52+
```
53+
54+
55+
```{python}
56+
validation.get_sundered_data(type="pass")
57+
```
58+
59+
```{python}
60+
validation.get_sundered_data(type="fail")
61+
```

requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@ PyYAML
44
pandas
55
pandera==0.21.0
66
pytest
7+
pointblank
8+
polars

0 commit comments

Comments
 (0)