@@ -9777,7 +9777,9 @@ def col_pct_null(
97779777 p: float,
97789778 tol: Tolerance = 0,
97799779 thresholds: int | float | None | bool | tuple | dict | Thresholds = None,
9780+ actions: Actions | None = None,
97809781 brief: str | bool | None = None,
9782+ active: bool = True,
97819783 ) -> Validate:
97829784 """
97839785 Validate whether a column has a specific percentage of Null values.
@@ -9810,12 +9812,20 @@ def col_pct_null(
98109812 `Validate(thresholds=...)`. The default is `None`, which means that no thresholds will
98119813 be set locally and global thresholds (if any) will take effect. Look at the *Thresholds*
98129814 section for information on how to set threshold levels.
9815+ actions
9816+ Optional actions to take when the validation step(s) meets or exceeds any set threshold
9817+ levels. If provided, the [`Actions`](`pointblank.Actions`) class should be used to
9818+ define the actions.
98139819 brief
98149820 An optional brief description of the validation step that will be displayed in the
98159821 reporting table. You can use the templating elements like `"{step}"` to insert
98169822 the step number, or `"{auto}"` to include an automatically generated brief. If `True`
98179823 the entire brief will be automatically generated. If `None` (the default) then there
98189824 won't be a brief.
9825+ active
9826+ A boolean value indicating whether the validation step should be active. Using `False`
9827+ will make the validation step inactive (still reporting its presence and keeping indexes
9828+ for the steps unchanged).
98199829
98209830 Returns
98219831 -------
@@ -10016,6 +10026,17 @@ def col_pct_null(
1001610026 This passes because 4 Null values falls within the acceptable range (3 - 0.3 to 3 + 0.9,
1001710027 which is 2.7 to 3.9).
1001810028 """
10029+ assertion_type = _get_fn_name()
10030+
10031+ _check_column(column=columns)
10032+ _check_thresholds(thresholds=thresholds)
10033+ _check_boolean_input(param=active, param_name="active")
10034+
10035+ # Determine threshold to use (global or local) and normalize a local `thresholds=` value
10036+ thresholds = (
10037+ self.thresholds if thresholds is None else _normalize_thresholds_creation(thresholds)
10038+ )
10039+
1001910040 # If `columns` is a ColumnSelector or Narwhals selector, call `col()` on it to later
1002010041 # resolve the columns
1002110042 if isinstance(columns, (ColumnSelector, nw.selectors.Selector)):
@@ -10030,20 +10051,16 @@ def col_pct_null(
1003010051
1003110052 bound_finder: Callable[[int], AbsoluteBounds] = partial(_derive_bounds, tol=tol)
1003210053
10033- thresholds = (
10034- self.thresholds if thresholds is None else _normalize_thresholds_creation(thresholds)
10035- )
10036-
1003710054 # Iterate over the columns and create a validation step for each
1003810055 for column in columns:
1003910056 val_info = _ValidationInfo(
10040- # TODO: should type hint these as required args i think
10041- assertion_type="col_pct_null",
10057+ assertion_type=assertion_type,
1004210058 column=column,
1004310059 values={"p": p, "bound_finder": bound_finder},
10044- brief=brief,
10045- active=True,
1004610060 thresholds=thresholds,
10061+ actions=actions,
10062+ brief=brief,
10063+ active=active,
1004710064 )
1004810065
1004910066 self._add_validation(validation_info=val_info)
0 commit comments