@@ -243,7 +243,7 @@ def _check_X_matches_training_df(X: pd.DataFrame, reference: int) -> None:
243243
244244
245245def _check_contains_na (
246- X : pd .DataFrame , variables : List [Union [str , int ]], switch_param : bool = False
246+ X : pd .DataFrame , variables : List [Union [str , int ]],
247247) -> None :
248248 """
249249 Checks if DataFrame contains null values in the selected columns.
@@ -255,9 +255,31 @@ def _check_contains_na(
255255 variables : List
256256 The selected group of variables in which null values will be examined.
257257
258- switch_param: bool
259- Whether the transformer has the parameter missing_values in the init to modify
260- its behaviour towards nan.
258+ Raises
259+ ------
260+ ValueError
261+ If the variable(s) contain null values.
262+ """
263+
264+ if X [variables ].isnull ().any ().any ():
265+ raise ValueError (
266+ "Some of the variables in the dataset contain NaN. Check and "
267+ "remove those before using this transformer."
268+ )
269+
270+
271+ def _check_optional_contains_na (
272+ X : pd .DataFrame , variables : List [Union [str , int ]]
273+ ) -> None :
274+ """
275+ Checks if DataFrame contains null values in the selected columns.
276+
277+ Parameters
278+ ----------
279+ X : Pandas DataFrame
280+
281+ variables : List
282+ The selected group of variables in which null values will be examined.
261283
262284 Raises
263285 ------
@@ -266,17 +288,11 @@ def _check_contains_na(
266288 """
267289
268290 if X [variables ].isnull ().any ().any ():
269- if switch_param is False :
270- raise ValueError (
271- "Some of the variables in the dataset contain NaN. Check and "
272- "remove those before using this transformer."
273- )
274- else :
275- raise ValueError (
276- "Some of the variables in the dataset contain NaN. Check and "
277- "remove those before using this transformer or set the parameter "
278- "`missing_values='ignore'` when initialising this transformer."
279- )
291+ raise ValueError (
292+ "Some of the variables in the dataset contain NaN. Check and "
293+ "remove those before using this transformer or set the parameter "
294+ "`missing_values='ignore'` when initialising this transformer."
295+ )
280296
281297
282298def _check_contains_inf (X : pd .DataFrame , variables : List [Union [str , int ]]) -> None :
0 commit comments