Skip to content

Commit 3068f77

Browse files
committed
Update validation-methods.qmd
1 parent 0120d2b commit 3068f77

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

docs/user-guide/validation-methods.qmd

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,32 @@ A very common thing to validate is that there are no Null/NA/missing values in a
174174

175175
Column `a` has no missing values and the above validation proves this.
176176

177+
### Checking Percentage of Missing Values
178+
179+
While `~~Validate.col_vals_not_null()` ensures there are no missing values at all, sometimes you
180+
need to validate that missing values match a specific percentage. The `~~Validate.col_pct_null()`
181+
method checks whether the percentage of missing values in a column matches an expected value:
182+
183+
```{python}
184+
(
185+
pb.Validate(data=pb.load_dataset(dataset="small_table", tbl_type="polars"))
186+
.col_pct_null(columns="c", p=0.15, tol=0.05) # Expect ~15% missing values (±5%)
187+
.interrogate()
188+
)
189+
```
190+
191+
This validation checks that approximately 15% of values in column `c` are missing, allowing a
192+
tolerance of ±5% (so the acceptable range is 10-20%). The `tol=` parameter can accept various
193+
formats including absolute counts or percentage ranges:
194+
195+
```{python}
196+
(
197+
pb.Validate(data=pb.load_dataset(dataset="small_table", tbl_type="polars"))
198+
.col_pct_null(columns="c", p=0.15, tol=(0.05, 0.10)) # Asymmetric tolerance: -5%/+10%
199+
.interrogate()
200+
)
201+
```
202+
177203
### Checking Strings with Regexes
178204

179205
A regular expression (regex) validation via the `~~Validate.col_vals_regex()` validation method

0 commit comments

Comments
 (0)