Repository: feature-engine/feature_engine
Pull request #714 (2023-12-10 17:47:05)

refactor find_or_check_categorical_variables

codecov[bot]: ## [Codecov](https://app.codecov.io/gh/feature-engine/feature_engine/pull/714?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=feature-engine) Report
All modified and coverable lines are covered by tests :white_check_mark:
> Comparison is base [(`795f888`)](https://app.codecov.io/gh/feature-engine/feature_engine/commit/795f88898d3be611baf2a337a6de923bbf062678?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=feature-engine) 98.00% compared to head [(`785aa8a`)](https://app.codecov.io/gh/feature-engine/feature_engine/pull/714?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=feature-engine) 98.00%.


<details><summary>Additional details and impacted files</summary>


```diff
@@           Coverage Diff           @@
##             main     #714   +/-   ##
=======================================
  Coverage   98.00%   98.00%           
=======================================
  Files         100      102    +2     
  Lines        3906     3919   +13     
  Branches      772      771    -1     
=======================================
+ Hits         3828     3841   +13     
  Misses         29       29           
  Partials       49       49           
```



</details>

[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/feature-engine/feature_engine/pull/714?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=feature-engine).   
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=feature-engine).


Patch:
diff --git a/docs/api_doc/variable_handling/check_categorical_variables.rst b/docs/api_doc/variable_handling/check_categorical_variables.rst
new file mode 100644
index 0000000..0d24276
--- /dev/null
+++ b/docs/api_doc/variable_handling/check_categorical_variables.rst
@@ -0,0 +1,6 @@
+check_categorical_variables
+===========================
+
+.. currentmodule:: feature_engine.variable_handling
+
+.. autofunction:: check_categorical_variables
\ No newline at end of file
diff --git a/docs/api_doc/variable_handling/find_categorical_variables.rst b/docs/api_doc/variable_handling/find_categorical_variables.rst
new file mode 100644
index 0000000..faa8703
--- /dev/null
+++ b/docs/api_doc/variable_handling/find_categorical_variables.rst
@@ -0,0 +1,6 @@
+﻿find_categorical_variables
+==========================
+
+.. currentmodule:: feature_engine.variable_handling
+
+.. autofunction:: find_categorical_variables
\ No newline at end of file
diff --git a/docs/api_doc/variable_handling/find_or_check_categorical_variables.rst b/docs/api_doc/variable_handling/find_or_check_categorical_variables.rst
deleted file mode 100644
index 5013573..0000000
--- a/docs/api_doc/variable_handling/find_or_check_categorical_variables.rst
+++ /dev/null
@@ -1,6 +0,0 @@
-﻿find_or_check_categorical_variables
-===================================
-
-.. currentmodule:: feature_engine.variable_handling
-
-.. autofunction:: find_or_check_categorical_variables
\ No newline at end of file
diff --git a/docs/api_doc/variable_handling/index.rst b/docs/api_doc/variable_handling/index.rst
index 0bae33c..97cbad9 100644
--- a/docs/api_doc/variable_handling/index.rst
+++ b/docs/api_doc/variable_handling/index.rst
@@ -18,8 +18,9 @@ variables that they will modify.
    :maxdepth: 1
 
    find_all_variables
+   find_categorical_variables
    find_numerical_variables
    find_categorical_and_numerical_variables
-   find_or_check_categorical_variables
    find_or_check_datetime_variables
+   check_categorical_variables
    check_numerical_variables
diff --git a/docs/user_guide/variable_handling/find_or_check_categorical_variables.rst b/docs/user_guide/variable_handling/check_categorical_variables.rst
similarity index 58%
rename from docs/user_guide/variable_handling/find_or_check_categorical_variables.rst
rename to docs/user_guide/variable_handling/check_categorical_variables.rst
index 7fa9a5a..ccdf7cb 100644
--- a/docs/user_guide/variable_handling/find_or_check_categorical_variables.rst
+++ b/docs/user_guide/variable_handling/check_categorical_variables.rst
@@ -1,12 +1,12 @@
-﻿.. _find_cat_vars:
+.. _check_cat_vars:
 
 .. currentmodule:: feature_engine.variable_handling.variable_type_selection
 
-find_or_check_categorical_variables
-===================================
+check_categorical_variables
+===========================
 
-With :class:`find_or_check_categorical_variables()` you can automatically capture in a list
-the names of all the variables of type object or categorical in the dataset.
+:class:`check_categorical_variables()` checks that the variables in the list are of
+type object or categorical.
 
 Let's create a toy dataset with numerical, categorical and datetime variables:
 
@@ -56,53 +56,33 @@ We see the resulting dataframe below:
     3 2020-02-24 00:03:00 2021-09-29 03:00:00  2020-02-24
     4 2020-02-24 00:04:00 2021-09-29 04:00:00  2020-02-24
 
-We can now use :class:`find_or_check_categorical_variables()` to capture the names of all
-variables of type object or categorical in a list.
 
-So let's do that and then display the list:
+Let's now check that 3 of the variables are of type numerical:
 
 .. code:: python
 
-    from feature_engine.variable_handling import find_or_check_categorical_variables
+    from feature_engine.variable_handling import check_categorical_variables
 
-    var_cat = find_or_check_categorical_variables(X)
+    var_cat = check_categorical_variables(X, ["cat_var1", "date3"])
 
     var_cat
 
-We see the variable names in the list below:
-
-.. code:: python
-
-    ['cat_var1', 'cat_var2']
-
-Note that when using the default parameters, :class:`find_or_check_categorical_variables()`
-will not return variables cast as object or categorical that could be parsed as datetime.
-Therefore, the variable `date3` was excluded from the returned list.
-
-We can force the function to select datetime variables cast as object as follows:
-
-.. code:: python
-
-    var_cat = find_or_check_categorical_variables(X, ["cat_var1", "date3"])
-
-    var_cat
-
-In this case, both variables, if object or categorical, will be in the resulting list:
+Both variables are of type object and hence, will be in the resulting list:
 
 .. code:: python
 
     ['cat_var1', 'date3']
 
-If we pass a variable that is not of type object or categorical, :class:`find_or_check_categorical_variables()`
-will return an error:
+If we pass a variable that is not of type object or categorical,
+:class:`check_categorical_variables()` will return an error:
 
 .. code:: python
 
-    find_or_check_categorical_variables(X, ["cat_var1", "num_var_1"])
+    check_categorical_variables(X, ["cat_var1", "num_var_1"])
 
 Below we see the error message:
 
 .. code:: python
 
-    TypeError: Some of the variables are not categorical. Please cast them as categorical
-    or object before using this transformer.
\ No newline at end of file
+    TypeError: Some of the variables are not categorical. Please cast them as object
+    or categorical before using this transformer.
\ No newline at end of file
diff --git a/docs/user_guide/variable_handling/find_categorical_variables.rst b/docs/user_guide/variable_handling/find_categorical_variables.rst
new file mode 100644
index 0000000..8febc7e
--- /dev/null
+++ b/docs/user_guide/variable_handling/find_categorical_variables.rst
@@ -0,0 +1,83 @@
+﻿.. _find_cat_vars:
+
+.. currentmodule:: feature_engine.variable_handling.variable_type_selection
+
+find_categorical_variables
+==========================
+
+With :class:`find_categorical_variables()` you can capture in a list the names of all
+the variables of type object or categorical in the dataset.
+
+Let's create a toy dataset with numerical, categorical and datetime variables:
+
+.. code:: python
+
+    import pandas as pd
+    from sklearn.datasets import make_classification
+
+    X, y = make_classification(
+        n_samples=1000,
+        n_features=4,
+        n_redundant=1,
+        n_clusters_per_class=1,
+        weights=[0.50],
+        class_sep=2,
+        random_state=1,
+    )
+
+    # transform arrays into pandas df and series
+    colnames = [f"num_var_{i+1}" for i in range(4)]
+    X = pd.DataFrame(X, columns=colnames)
+
+    X["cat_var1"] = ["Hello"] * 1000
+    X["cat_var2"] = ["Bye"] * 1000
+
+    X["date1"] = pd.date_range("2020-02-24", periods=1000, freq="T")
+    X["date2"] = pd.date_range("2021-09-29", periods=1000, freq="H")
+    X["date3"] = ["2020-02-24"] * 1000
+
+    print(X.head())
+
+We see the resulting dataframe below:
+
+.. code:: python
+
+       num_var_1  num_var_2  num_var_3  num_var_4 cat_var1 cat_var2  \
+    0  -1.558594   1.634123   1.556932   2.869318    Hello      Bye
+    1   1.499925   1.651008   1.159977   2.510196    Hello      Bye
+    2   0.277127  -0.263527   0.532159   0.274491    Hello      Bye
+    3  -1.139190  -1.131193   2.296540   1.189781    Hello      Bye
+    4  -0.530061  -2.280109   2.469580   0.365617    Hello      Bye
+
+                    date1               date2       date3
+    0 2020-02-24 00:00:00 2021-09-29 00:00:00  2020-02-24
+    1 2020-02-24 00:01:00 2021-09-29 01:00:00  2020-02-24
+    2 2020-02-24 00:02:00 2021-09-29 02:00:00  2020-02-24
+    3 2020-02-24 00:03:00 2021-09-29 03:00:00  2020-02-24
+    4 2020-02-24 00:04:00 2021-09-29 04:00:00  2020-02-24
+
+We can use :class:`find_categorical_variables()` to capture the names of all
+variables of type object or categorical in a list.
+
+So let's do that and then display the list:
+
+.. code:: python
+
+    from feature_engine.variable_handling import find_categorical_variables
+
+    var_cat = find_categorical_variables(X)
+
+    var_cat
+
+We see the variable names in the list below:
+
+.. code:: python
+
+    ['cat_var1', 'cat_var2']
+
+Note that :class:`find_categorical_variables()` will not return variables cast as
+object or categorical that could be parsed as datetime. That's why, the variable
+`date3` was excluded from the returned list.
+
+If there are no categorical variables in the dataset, this function will raise an
+error.
\ No newline at end of file
diff --git a/docs/user_guide/variable_handling/index.rst b/docs/user_guide/variable_handling/index.rst
index 2455f1d..0b65817 100644
--- a/docs/user_guide/variable_handling/index.rst
+++ b/docs/user_guide/variable_handling/index.rst
@@ -20,8 +20,9 @@ Feature-engine or Scikit-learn compatible transformers.
    :maxdepth: 1
 
    find_all_variables
+   find_categorical_variables
    find_numerical_variables
    find_categorical_and_numerical_variables
-   find_or_check_categorical_variables
    find_or_check_datetime_variables
+   check_categorical_variables
    check_numerical_variables
diff --git a/feature_engine/_base_transformers/base_numerical.py b/feature_engine/_base_transformers/base_numerical.py
index 602415e..2158ae1 100644
--- a/feature_engine/_base_transformers/base_numerical.py
+++ b/feature_engine/_base_transformers/base_numerical.py
@@ -15,7 +15,7 @@ from feature_engine.dataframe_checks import (
     check_X,
 )
 from feature_engine.tags import _return_tags
-from feature_engine.variable_handling.variable_selection import (
+from feature_engine.variable_handling import (
     find_numerical_variables,
     check_numerical_variables,
 )
diff --git a/feature_engine/_base_transformers/mixins.py b/feature_engine/_base_transformers/mixins.py
index 8154eb9..8356c4a 100644
--- a/feature_engine/_base_transformers/mixins.py
+++ b/feature_engine/_base_transformers/mixins.py
@@ -10,9 +10,7 @@ from feature_engine.dataframe_checks import (
     _check_contains_na,
     check_X,
 )
-from feature_engine.variable_handling.variable_selection import (
-    check_numerical_variables,
-)
+from feature_engine.variable_handling import check_numerical_variables
 
 
 class FitFromDictMixin:
diff --git a/feature_engine/creation/base_creation.py b/feature_engine/creation/base_creation.py
index 81257e9..8a61573 100644
--- a/feature_engine/creation/base_creation.py
+++ b/feature_engine/creation/base_creation.py
@@ -16,7 +16,7 @@ from feature_engine.dataframe_checks import (
     check_X,
 )
 from feature_engine.tags import _return_tags
-from feature_engine.variable_handling.variable_selection import (
+from feature_engine.variable_handling import (
     find_numerical_variables,
     check_numerical_variables,
 )
diff --git a/feature_engine/encoding/base_encoder.py b/feature_engine/encoding/base_encoder.py
index 97655ca..1b7025e 100644
--- a/feature_engine/encoding/base_encoder.py
+++ b/feature_engine/encoding/base_encoder.py
@@ -21,9 +21,10 @@ from feature_engine.tags import _return_tags
 from feature_engine._check_init_parameters.check_variables import (
     _check_variables_input_value,
 )
-from feature_engine.variable_handling.variable_selection import (
+from feature_engine.variable_handling import (
     find_all_variables,
-    find_or_check_categorical_variables,
+    find_categorical_variables,
+    check_categorical_variables,
 )
 
 
@@ -130,14 +131,14 @@ class CategoricalMethodsMixin(BaseEstimator, TransformerMixin, GetFeatureNamesOu
             If there are no categorical variables in the df or the df is empty
             If the variable(s) contain null values
         """
-        if self.ignore_format is False:
-            # find categorical variables or check variables entered by user are object
-            variables_: List[Union[str, int]] = find_or_check_categorical_variables(
-                X, self.variables
-            )
-        else:
-            # select all variables or check variables entered by the user
+        # select variables to encode
+        if self.ignore_format is True:
             variables_ = find_all_variables(X, self.variables)
+        else:
+            if self.variables is None:
+                variables_ = find_categorical_variables(X)
+            else:
+                variables_ = check_categorical_variables(X, self.variables)
 
         return variables_
 
diff --git a/feature_engine/imputation/arbitrary_number.py b/feature_engine/imputation/arbitrary_number.py
index 91d5c95..2ea30f7 100644
--- a/feature_engine/imputation/arbitrary_number.py
+++ b/feature_engine/imputation/arbitrary_number.py
@@ -25,7 +25,7 @@ from feature_engine.imputation.base_imputer import BaseImputer
 from feature_engine._check_init_parameters.check_variables import (
     _check_variables_input_value,
 )
-from feature_engine.variable_handling.variable_selection import (
+from feature_engine.variable_handling import (
     find_numerical_variables,
     check_numerical_variables,
 )
diff --git a/feature_engine/imputation/categorical.py b/feature_engine/imputation/categorical.py
index a1b3402..4542bf5 100644
--- a/feature_engine/imputation/categorical.py
+++ b/feature_engine/imputation/categorical.py
@@ -22,9 +22,10 @@ from feature_engine.tags import _return_tags
 from feature_engine._check_init_parameters.check_variables import (
     _check_variables_input_value,
 )
-from feature_engine.variable_handling.variable_selection import (
+from feature_engine.variable_handling import (
     find_all_variables,
-    find_or_check_categorical_variables,
+    find_categorical_variables,
+    check_categorical_variables,
 )
 
 
@@ -164,16 +165,14 @@ class CategoricalImputer(BaseImputer):
         # check input dataframe
         X = check_X(X)
 
-        # check or select the the right variables
-        if not self.ignore_format:
-            # find categorical variables or check variables entered by user are
-            # categorical
-            self.variables_: List[
-                Union[str, int]
-            ] = find_or_check_categorical_variables(X, self.variables)
-        else:
-            # select all variables or check variables entered by the user
+        # select variables to encode
+        if self.ignore_format is True:
             self.variables_ = find_all_variables(X, self.variables)
+        else:
+            if self.variables is None:
+                self.variables_ = find_categorical_variables(X)
+            else:
+                self.variables_ = check_categorical_variables(X, self.variables)
 
         if self.imputation_method == "missing":
             self.imputer_dict_ = {var: self.fill_value for var in self.variables_}
diff --git a/feature_engine/imputation/end_tail.py b/feature_engine/imputation/end_tail.py
index 42356cc..3b39448 100644
--- a/feature_engine/imputation/end_tail.py
+++ b/feature_engine/imputation/end_tail.py
@@ -24,7 +24,7 @@ from feature_engine.imputation.base_imputer import BaseImputer
 from feature_engine._check_init_parameters.check_variables import (
     _check_variables_input_value,
 )
-from feature_engine.variable_handling.variable_selection import (
+from feature_engine.variable_handling import (
     find_numerical_variables,
     check_numerical_variables,
 )
diff --git a/feature_engine/imputation/mean_median.py b/feature_engine/imputation/mean_median.py
index 8ea81e4..5c54dad 100644
--- a/feature_engine/imputation/mean_median.py
+++ b/feature_engine/imputation/mean_median.py
@@ -24,7 +24,7 @@ from feature_engine.imputation.base_imputer import BaseImputer
 from feature_engine._check_init_parameters.check_variables import (
     _check_variables_input_value,
 )
-from feature_engine.variable_handling.variable_selection import (
+from feature_engine.variable_handling import (
     find_numerical_variables,
     check_numerical_variables,
 )
diff --git a/feature_engine/outliers/artbitrary.py b/feature_engine/outliers/artbitrary.py
index 97f43f8..7f06a70 100644
--- a/feature_engine/outliers/artbitrary.py
+++ b/feature_engine/outliers/artbitrary.py
@@ -31,9 +31,7 @@ from feature_engine.dataframe_checks import (
 )
 from feature_engine.outliers.base_outlier import BaseOutlier
 from feature_engine.tags import _return_tags
-from feature_engine.variable_handling.variable_selection import (
-    check_numerical_variables,
-)
+from feature_engine.variable_handling import check_numerical_variables
 
 
 @Substitution(
diff --git a/feature_engine/outliers/base_outlier.py b/feature_engine/outliers/base_outlier.py
index 1f1774a..504a127 100644
--- a/feature_engine/outliers/base_outlier.py
+++ b/feature_engine/outliers/base_outlier.py
@@ -15,7 +15,7 @@ from feature_engine.tags import _return_tags
 from feature_engine._check_init_parameters.check_variables import (
     _check_variables_input_value,
 )
-from feature_engine.variable_handling.variable_selection import (
+from feature_engine.variable_handling import (
     find_numerical_variables,
     check_numerical_variables,
 )
diff --git a/feature_engine/selection/base_recursive_selector.py b/feature_engine/selection/base_recursive_selector.py
index 854a557..1029c1c 100644
--- a/feature_engine/selection/base_recursive_selector.py
+++ b/feature_engine/selection/base_recursive_selector.py
@@ -9,7 +9,7 @@ from feature_engine.tags import _return_tags
 from feature_engine._check_init_parameters.check_variables import (
     _check_variables_input_value,
 )
-from feature_engine.variable_handling.variable_selection import (
+from feature_engine.variable_handling import (
     find_numerical_variables,
     check_numerical_variables,
 )
diff --git a/feature_engine/selection/drop_correlated_features.py b/feature_engine/selection/drop_correlated_features.py
index 30b3424..0bc0342 100644
--- a/feature_engine/selection/drop_correlated_features.py
+++ b/feature_engine/selection/drop_correlated_features.py
@@ -26,7 +26,7 @@ from feature_engine.selection.base_selector import BaseSelector
 from feature_engine._check_init_parameters.check_variables import (
     _check_variables_input_value,
 )
-from feature_engine.variable_handling.variable_selection import (
+from feature_engine.variable_handling import (
     find_numerical_variables,
     check_numerical_variables,
 )
diff --git a/feature_engine/selection/shuffle_features.py b/feature_engine/selection/shuffle_features.py
index 00b7817..1f42112 100644
--- a/feature_engine/selection/shuffle_features.py
+++ b/feature_engine/selection/shuffle_features.py
@@ -35,7 +35,7 @@ from feature_engine.tags import _return_tags
 from feature_engine._check_init_parameters.check_variables import (
     _check_variables_input_value,
 )
-from feature_engine.variable_handling.variable_selection import (
+from feature_engine.variable_handling import (
     find_numerical_variables,
     check_numerical_variables,
 )
diff --git a/feature_engine/selection/single_feature_performance.py b/feature_engine/selection/single_feature_performance.py
index 311e852..8c40c17 100644
--- a/feature_engine/selection/single_feature_performance.py
+++ b/feature_engine/selection/single_feature_performance.py
@@ -32,7 +32,7 @@ from feature_engine.tags import _return_tags
 from feature_engine._check_init_parameters.check_variables import (
     _check_variables_input_value,
 )
-from feature_engine.variable_handling.variable_selection import (
+from feature_engine.variable_handling import (
     find_numerical_variables,
     check_numerical_variables,
 )
diff --git a/feature_engine/selection/smart_correlation_selection.py b/feature_engine/selection/smart_correlation_selection.py
index 028e1c4..f1b62ac 100644
--- a/feature_engine/selection/smart_correlation_selection.py
+++ b/feature_engine/selection/smart_correlation_selection.py
@@ -30,7 +30,7 @@ from feature_engine.selection.base_selector import BaseSelector
 from feature_engine._check_init_parameters.check_variables import (
     _check_variables_input_value,
 )
-from feature_engine.variable_handling.variable_selection import (
+from feature_engine.variable_handling import (
     find_numerical_variables,
     check_numerical_variables,
 )
diff --git a/feature_engine/timeseries/forecasting/base_forecast_transformers.py b/feature_engine/timeseries/forecasting/base_forecast_transformers.py
index 71cbba1..2bb55fe 100644
--- a/feature_engine/timeseries/forecasting/base_forecast_transformers.py
+++ b/feature_engine/timeseries/forecasting/base_forecast_transformers.py
@@ -25,7 +25,7 @@ from feature_engine.tags import _return_tags
 from feature_engine._check_init_parameters.check_variables import (
     _check_variables_input_value,
 )
-from feature_engine.variable_handling.variable_selection import (
+from feature_engine.variable_handling import (
     find_numerical_variables,
     check_numerical_variables,
 )
diff --git a/feature_engine/variable_handling/__init__.py b/feature_engine/variable_handling/__init__.py
index e00651f..65b7a2d 100644
--- a/feature_engine/variable_handling/__init__.py
+++ b/feature_engine/variable_handling/__init__.py
@@ -6,18 +6,17 @@ or check that a list of variables is in certain type.
 from .variable_selection import (
     find_all_variables,
     find_categorical_and_numerical_variables,
-    find_or_check_categorical_variables,
     find_or_check_datetime_variables,
-    find_numerical_variables,
-    check_numerical_variables,
-
 )
+from .check_variables import check_numerical_variables, check_categorical_variables
+from .find_variables import find_numerical_variables, find_categorical_variables
 
 __all__ = [
     "find_all_variables",
     "find_categorical_and_numerical_variables",
-    "find_or_check_categorical_variables",
     "find_or_check_datetime_variables",
-    "find_numerical_variables",
     "check_numerical_variables",
+    "check_categorical_variables",
+    "find_numerical_variables",
+    "find_categorical_variables",
 ]
diff --git a/feature_engine/variable_handling/check_variables.py b/feature_engine/variable_handling/check_variables.py
new file mode 100644
index 0000000..bff9fe6
--- /dev/null
+++ b/feature_engine/variable_handling/check_variables.py
@@ -0,0 +1,99 @@
+from typing import List, Union
+
+import pandas as pd
+
+Variables = Union[int, str, List[Union[str, int]]]
+
+
+def check_numerical_variables(
+    X: pd.DataFrame, variables: Variables
+) -> List[Union[str, int]]:
+    """
+    Checks that the variables in the list are of type numerical.
+
+    More details in the :ref:`User Guide <check_num_vars>`.
+
+    Parameters
+    ----------
+    X : pandas dataframe of shape = [n_samples, n_features]
+        The dataset
+
+    variables : List
+        List with the names of the variables to check.
+
+    Returns
+    -------
+    variables: List
+        The names of the numerical variables.
+
+    Examples
+    --------
+    >>> import pandas as pd
+    >>> from feature_engine.variable_handling import check_numerical_variables
+    >>> X = pd.DataFrame({
+    >>>     "var_num": [1, 2, 3],
+    >>>     "var_cat": ["A", "B", "C"],
+    >>>     "var_date": pd.date_range("2020-02-24", periods=3, freq="T")
+    >>> })
+    >>> var_ = check_numerical_variables(X, variables=["var_num"])
+    >>> var_
+    ['var_num']
+    """
+
+    if isinstance(variables, (str, int)):
+        variables = [variables]
+
+    if len(X[variables].select_dtypes(exclude="number").columns) > 0:
+        raise TypeError(
+            "Some of the variables are not numerical. Please cast them as "
+            "numerical before using this transformer."
+        )
+
+    return variables
+
+
+def check_categorical_variables(
+    X: pd.DataFrame, variables: Variables
+) -> List[Union[str, int]]:
+    """
+    Checks that the variables in the list are of type object or categorical.
+
+    More details in the :ref:`User Guide <check_cat_vars>`.
+
+    Parameters
+    ----------
+    X : pandas dataframe of shape = [n_samples, n_features]
+        The dataset
+
+    variables : list
+        List with the names of the variables to check.
+
+    Returns
+    -------
+    variables: List
+        The names of the categorical variables.
+
+    Examples
+    --------
+    >>> import pandas as pd
+    >>> from feature_engine.variable_handling import check_categorical_variables
+    >>> X = pd.DataFrame({
+    >>>     "var_num": [1, 2, 3],
+    >>>     "var_cat": ["A", "B", "C"],
+    >>>     "var_date": pd.date_range("2020-02-24", periods=3, freq="T")
+    >>> })
+    >>> var_ = check_categorical_variables(X, "var_cat")
+    >>> var_
+    ['var_cat']
+    """
+
+    if isinstance(variables, (str, int)):
+        variables = [variables]
+
+    if len(X[variables].select_dtypes(exclude=["O", "category"]).columns) > 0:
+        raise TypeError(
+            "Some of the variables are not categorical. Please cast them as "
+            "object or categorical before using this transformer."
+        )
+
+    return variables
diff --git a/feature_engine/variable_handling/find_variables.py b/feature_engine/variable_handling/find_variables.py
new file mode 100644
index 0000000..0b0c803
--- /dev/null
+++ b/feature_engine/variable_handling/find_variables.py
@@ -0,0 +1,89 @@
+from typing import List, Union
+
+import pandas as pd
+
+from feature_engine.variable_handling._variable_type_checks import (
+    _is_categorical_and_is_not_datetime,
+)
+
+
+def find_numerical_variables(X: pd.DataFrame) -> List[Union[str, int]]:
+    """
+    Returns a list with the names of all the numerical variables in a dataframe.
+
+    More details in the :ref:`User Guide <find_num_vars>`.
+
+    Parameters
+    ----------
+    X : pandas dataframe of shape = [n_samples, n_features]
+        The dataset
+
+    Returns
+    -------
+    variables: List
+        The names of the numerical variables.
+
+    Examples
+    --------
+    >>> import pandas as pd
+    >>> from feature_engine.variable_handling import find_numerical_variables
+    >>> X = pd.DataFrame({
+    >>>     "var_num": [1, 2, 3],
+    >>>     "var_cat": ["A", "B", "C"],
+    >>>     "var_date": pd.date_range("2020-02-24", periods=3, freq="T")
+    >>> })
+    >>> var_ = find_numerical_variables(X)
+    >>> var_
+    ['var_num']
+    """
+    variables = list(X.select_dtypes(include="number").columns)
+    if len(variables) == 0:
+        raise TypeError(
+            "No numerical variables found in this dataframe. Please check "
+            "variable format with pandas dtypes."
+        )
+    return variables
+
+
+def find_categorical_variables(X: pd.DataFrame) -> List[Union[str, int]]:
+    """
+    Returns a list with the names of all the categorical variables in a dataframe.
+    Note that variables cast as object that can be parsed to datetime will be
+    excluded.
+
+    More details in the :ref:`User Guide <find_cat_vars>`.
+
+    Parameters
+    ----------
+    X : pandas dataframe of shape = [n_samples, n_features]
+        The dataset
+
+    Returns
+    -------
+    variables: List
+        The names of the categorical variables.
+
+    Examples
+    --------
+    >>> import pandas as pd
+    >>> from feature_engine.variable_handling import find_categorical_variables
+    >>> X = pd.DataFrame({
+    >>>     "var_num": [1, 2, 3],
+    >>>     "var_cat": ["A", "B", "C"],
+    >>>     "var_date": pd.date_range("2020-02-24", periods=3, freq="T")
+    >>> })
+    >>> var_ = find_categorical_variables(X)
+    >>> var_
+    ['var_cat']
+    """
+    variables = [
+        column
+        for column in X.select_dtypes(include=["O", "category"]).columns
+        if _is_categorical_and_is_not_datetime(X[column])
+    ]
+    if len(variables) == 0:
+        raise TypeError(
+            "No categorical variables found in this dataframe. Please check "
+            "variable format with pandas dtypes."
+        )
+    return variables
diff --git a/feature_engine/variable_handling/variable_selection.py b/feature_engine/variable_handling/variable_selection.py
index 0580465..61de359 100644
--- a/feature_engine/variable_handling/variable_selection.py
+++ b/feature_engine/variable_handling/variable_selection.py
@@ -13,170 +13,6 @@ from feature_engine.variable_handling._variable_type_checks import (
 )
 
 Variables = Union[None, int, str, List[Union[str, int]]]
-Variables_tmp = Union[int, str, List[Union[str, int]]]
-
-
-def find_numerical_variables(X: pd.DataFrame) -> List[Union[str, int]]:
-    """
-    Returns a list with the names of all the numerical variables in a dataframe.
-
-    More details in the :ref:`User Guide <find_num_vars>`.
-
-    Parameters
-    ----------
-    X : pandas dataframe of shape = [n_samples, n_features]
-        The dataset
-
-    Returns
-    -------
-    variables: List
-        The names of the numerical variables.
-
-    Examples
-    --------
-    >>> import pandas as pd
-    >>> from feature_engine.variable_handling import find_numerical_variables
-    >>> X = pd.DataFrame({
-    >>>     "var_num": [1, 2, 3],
-    >>>     "var_cat": ["A", "B", "C"],
-    >>>     "var_date": pd.date_range("2020-02-24", periods=3, freq="T")
-    >>> })
-    >>> var_num = find_numerical_variables(X)
-    >>> var_num
-    ['var_num']
-    """
-    variables = list(X.select_dtypes(include="number").columns)
-    if len(variables) == 0:
-        raise TypeError(
-            "No numerical variables found in this dataframe. Please check "
-            "variable format with pandas dtypes."
-        )
-    return variables
-
-
-def check_numerical_variables(
-    X: pd.DataFrame, variables: Variables_tmp
-) -> List[Union[str, int]]:
-    """
-    Checks that the variables in the list are of type numerical.
-
-    More details in the :ref:`User Guide <check_num_vars>`.
-
-    Parameters
-    ----------
-    X : pandas dataframe of shape = [n_samples, n_features]
-        The dataset
-
-    variables : List
-        List with the names of the variables to check.
-
-    Returns
-    -------
-    variables: List
-        The names of the numerical variables.
-
-    Examples
-    --------
-    >>> import pandas as pd
-    >>> from feature_engine.variable_handling import check_numerical_variables
-    >>> X = pd.DataFrame({
-    >>>     "var_num": [1, 2, 3],
-    >>>     "var_cat": ["A", "B", "C"],
-    >>>     "var_date": pd.date_range("2020-02-24", periods=3, freq="T")
-    >>> })
-    >>> var_num = check_numerical_variables(X, variables=["var_num"])
-    >>> var_num
-    ['var_num']
-    """
-
-    if isinstance(variables, (str, int)):
-        variables = [variables]
-
-    if len(X[variables].select_dtypes(exclude="number").columns) > 0:
-        raise TypeError(
-            "Some of the variables are not numerical. Please cast them as "
-            "numerical before using this transformer."
-        )
-
-    return variables
-
-
-def find_or_check_categorical_variables(
-    X: pd.DataFrame, variables: Variables = None
-) -> List[Union[str, int]]:
-    """
-    Returns the names of all the variables of type object or categorical in a dataframe.
-    Alternatively, it checks that the variables entered by the user are of type object
-    or categorical.
-
-    Note that when `variables` is `None`, the transformer will not select variables of
-    type object that can be parsed as datetime. But if the user passes a list with
-    datetime variables cast as object to the `variables` parameter, they will be
-    allowed.
-
-    More details in the :ref:`User Guide <find_cat_vars>`.
-
-    Parameters
-    ----------
-    X : pandas dataframe of shape = [n_samples, n_features]
-        The dataset
-
-    variables : list, default=None
-        If `None`, the function returns the names of all object or categorical variables
-        in X. Alternatively, it checks that the variables in the list are of type
-        object or categorical.
-
-    Returns
-    -------
-    variables: List
-        The names of the categorical variables.
-
-    Examples
-    --------
-    >>> import pandas as pd
-    >>> from feature_engine.variable_handling import find_or_check_categorical_variables
-    >>> X = pd.DataFrame({
-    >>>     "var_num": [1, 2, 3],
-    >>>     "var_cat": ["A", "B", "C"],
-    >>>     "var_date": pd.date_range("2020-02-24", periods=3, freq="T")
-    >>> })
-    >>> var_cat = find_or_check_categorical_variables(X)
-    >>> var_cat
-    ['var_cat']
-    """
-
-    if variables is None:
-        # find categorical variables in dataset
-        variables = [
-            column
-            for column in X.select_dtypes(include=["O", "category"]).columns
-            if _is_categorical_and_is_not_datetime(X[column])
-        ]
-        if len(variables) == 0:
-            raise ValueError(
-                "No categorical variables found in this dataframe. Please check "
-                "variable format with pandas dtypes."
-            )
-
-    elif isinstance(variables, (str, int)):
-        if X[variables].dtype.name == "category" or is_object(X[variables]):
-            variables = [variables]
-        else:
-            raise TypeError("The variable entered is not categorical.")
-
-    else:
-        if len(variables) == 0:
-            raise ValueError("The list of variables is empty.")
-
-        # check that user entered variables are of type categorical
-        else:
-            if len(X[variables].select_dtypes(exclude=["O", "category"]).columns) > 0:
-                raise TypeError(
-                    "Some of the variables are not categorical. Please cast them as "
-                    "categorical or object before using this transformer."
-                )
-
-    return variables
 
 
 def find_or_check_datetime_variables(
diff --git a/feature_engine/wrappers/wrappers.py b/feature_engine/wrappers/wrappers.py
index ab5876d..61764d8 100644
--- a/feature_engine/wrappers/wrappers.py
+++ b/feature_engine/wrappers/wrappers.py
@@ -11,6 +11,8 @@ from feature_engine._check_init_parameters.check_variables import (
 )
 from feature_engine.variable_handling.variable_selection import (
     find_all_variables,
+)
+from feature_engine.variable_handling import (
     find_numerical_variables,
     check_numerical_variables,
 )


Test patch:
diff --git a/tests/test_check_init_parameters/test_check_variables.py b/tests/test_check_init_parameters/test_check_variables.py
index 9c95bef..8b55805 100644
--- a/tests/test_check_init_parameters/test_check_variables.py
+++ b/tests/test_check_init_parameters/test_check_variables.py
@@ -7,7 +7,7 @@ from feature_engine._check_init_parameters.check_variables import (
 
 @pytest.mark.parametrize("_input_vars", [("var1", "var2"), {"var1": 1, "var2": 2}])
 def test_raises_errors_when_not_list_str_or_int(_input_vars):
-    with pytest.raises(ValueError)as record:
+    with pytest.raises(ValueError) as record:
         assert _check_variables_input_value(_input_vars)
     msg = (
         "`variables` should contain a string, an integer or a list of strings or "
diff --git a/tests/test_datetime/test_datetime_features.py b/tests/test_datetime/test_datetime_features.py
index de8d990..e1eb054 100644
--- a/tests/test_datetime/test_datetime_features.py
+++ b/tests/test_datetime/test_datetime_features.py
@@ -353,7 +353,10 @@ def test_extract_features_from_different_timezones_when_string(
         {"time_obj": df_datetime["time_obj"].add(["+4", "-1", "+9", "-7"])}
     )
     transformer = DatetimeFeatures(
-        variables="time_obj", features_to_extract=["hour"], utc=True, format="mixed",
+        variables="time_obj",
+        features_to_extract=["hour"],
+        utc=True,
+        format="mixed",
     )
     X = transformer.fit_transform(tz_df)
 
diff --git a/tests/test_transformation/test_yeojohnson_transformer.py b/tests/test_transformation/test_yeojohnson_transformer.py
index a9d4a20..f6cb51b 100644
--- a/tests/test_transformation/test_yeojohnson_transformer.py
+++ b/tests/test_transformation/test_yeojohnson_transformer.py
@@ -134,12 +134,7 @@ def test_lambda_equals_lambda_equal_0():
 
 
 def test_lambda_equals_lambda_equal_2():
-    X = pd.DataFrame(
-        {
-            "var1": np.arange(-21, -1),
-            "var2": np.arange(-41, -21)
-        }
-    )
+    X = pd.DataFrame({"var1": np.arange(-21, -1), "var2": np.arange(-41, -21)})
 
     transformer = YeoJohnsonTransformer(variables=None)
     transformer = transformer.fit(X)
diff --git a/tests/test_variable_handling/test_check_variables.py b/tests/test_variable_handling/test_check_variables.py
new file mode 100644
index 0000000..387c8d1
--- /dev/null
+++ b/tests/test_variable_handling/test_check_variables.py
@@ -0,0 +1,108 @@
+import pandas as pd
+import pytest
+
+from feature_engine.variable_handling import (
+    check_numerical_variables,
+    check_categorical_variables,
+)
+
+df = pd.DataFrame(
+    {
+        "Name": ["tom", "nick", "krish", "jack"],
+        "City": ["London", "Manchester", "Liverpool", "Bristol"],
+        "Age": [20, 21, 19, 18],
+        "Marks": [0.9, 0.8, 0.7, 0.6],
+        "dob": pd.date_range("2020-02-24", periods=4, freq="T"),
+        "date": ["2020-02-24", "2020-02-25", "2020-02-26", "2020-02-27"],
+    }
+)
+df["Name"] = df["Name"].astype("category")
+
+df_int = pd.DataFrame(
+    {
+        1: ["tom", "nick", "krish", "jack"],
+        2: ["London", "Manchester", "Liverpool", "Bristol"],
+        3: [20, 21, 19, 18],
+        4: [0.9, 0.8, 0.7, 0.6],
+        5: pd.date_range("2020-02-24", periods=4, freq="T"),
+    }
+)
+df_int[1] = df_int[1].astype("category")
+
+
+def test_check_numerical_variables_returns_numerical_variables():
+    assert check_numerical_variables(df, ["Age", "Marks"]) == ["Age", "Marks"]
+    assert check_numerical_variables(df, ["Age"]) == ["Age"]
+    assert check_numerical_variables(df, "Age") == ["Age"]
+    assert check_numerical_variables(df_int, [3, 4]) == [3, 4]
+    assert check_numerical_variables(df_int, [3]) == [3]
+    assert check_numerical_variables(df_int, 4) == [4]
+
+
+def test_check_numerical_variables_raises_errors_when_not_numerical():
+    msg = (
+        "Some of the variables are not numerical. Please cast them as "
+        "numerical before using this transformer."
+    )
+    with pytest.raises(TypeError) as record:
+        assert check_numerical_variables(df, "Name")
+    assert str(record.value) == msg
+
+    with pytest.raises(TypeError) as record:
+        assert check_numerical_variables(df, ["Name"])
+    assert str(record.value) == msg
+
+    with pytest.raises(TypeError) as record:
+        assert check_numerical_variables(df_int, 1)
+    assert str(record.value) == msg
+
+    with pytest.raises(TypeError) as record:
+        assert check_numerical_variables(df_int, [1])
+    assert str(record.value) == msg
+
+    with pytest.raises(TypeError) as record:
+        assert check_numerical_variables(df, ["Name", "Marks"])
+    assert str(record.value) == msg
+
+    with pytest.raises(TypeError) as record:
+        assert check_numerical_variables(df_int, [2, 3])
+    assert str(record.value) == msg
+
+
+def test_check_categorical_variables_returns_categorical_variables():
+    assert check_categorical_variables(df, ["Name", "date"]) == ["Name", "date"]
+    assert check_categorical_variables(df, ["Name"]) == ["Name"]
+    assert check_categorical_variables(df, "date") == ["date"]
+    assert check_categorical_variables(df_int, [1, 2]) == [1, 2]
+    assert check_categorical_variables(df_int, [2]) == [2]
+    assert check_categorical_variables(df_int, 2) == [2]
+
+
+def test_check_categorical_variables_raises_errors_when_not_categorical():
+    msg = (
+        "Some of the variables are not categorical. Please cast them as "
+        "object or categorical before using this transformer."
+    )
+    with pytest.raises(TypeError) as record:
+        assert check_categorical_variables(df, "Age")
+    assert str(record.value) == msg
+
+    with pytest.raises(TypeError) as record:
+        assert check_categorical_variables(df, ["Age"])
+    assert str(record.value) == msg
+
+    with pytest.raises(TypeError) as record:
+        assert check_categorical_variables(df_int, 3)
+    assert str(record.value) == msg
+
+    with pytest.raises(TypeError) as record:
+        assert check_categorical_variables(df_int, [3])
+    assert str(record.value) == msg
+
+    with pytest.raises(TypeError) as record:
+        assert check_categorical_variables(df, ["Name", "Marks"])
+    assert str(record.value) == msg
+
+    with pytest.raises(TypeError) as record:
+        assert check_categorical_variables(df_int, [2, 3])
+    assert str(record.value) == msg
diff --git a/tests/test_variable_handling/test_find_variables.py b/tests/test_variable_handling/test_find_variables.py
new file mode 100644
index 0000000..aafb8f2
--- /dev/null
+++ b/tests/test_variable_handling/test_find_variables.py
@@ -0,0 +1,68 @@
+import pandas as pd
+import pytest
+
+from feature_engine.variable_handling import (
+    find_numerical_variables,
+    find_categorical_variables,
+)
+
+df = pd.DataFrame(
+    {
+        "Name": ["tom", "nick", "krish", "jack"],
+        "City": ["London", "Manchester", "Liverpool", "Bristol"],
+        "Age": [20, 21, 19, 18],
+        "Marks": [0.9, 0.8, 0.7, 0.6],
+        "dob": pd.date_range("2020-02-24", periods=4, freq="T"),
+        "date": ["2020-02-24", "2020-02-25", "2020-02-26", "2020-02-27"],
+    }
+)
+df["Name"] = df["Name"].astype("category")
+
+df_int = pd.DataFrame(
+    {
+        1: ["tom", "nick", "krish", "jack"],
+        2: ["London", "Manchester", "Liverpool", "Bristol"],
+        3: [20, 21, 19, 18],
+        4: [0.9, 0.8, 0.7, 0.6],
+        5: pd.date_range("2020-02-24", periods=4, freq="T"),
+    }
+)
+df_int[1] = df_int[1].astype("category")
+
+
+def test_numerical_variables_finds_numerical_variables():
+    assert find_numerical_variables(df) == ["Age", "Marks"]
+    assert find_numerical_variables(df_int) == [3, 4]
+
+
+def test_numerical_variables_raises_error_when_no_numerical_variables():
+    msg = (
+        "No numerical variables found in this dataframe. Please check "
+        "variable format with pandas dtypes."
+    )
+    with pytest.raises(TypeError) as record:
+        assert find_numerical_variables(df.drop(["Age", "Marks"], axis=1))
+    assert str(record.value) == msg
+
+    with pytest.raises(TypeError) as record:
+        assert find_numerical_variables(df_int.drop([3, 4], axis=1))
+    assert str(record.value) == msg
+
+
+def test_categorical_variables_finds_categorical_variables():
+    assert find_categorical_variables(df) == ["Name", "City"]
+    assert find_categorical_variables(df_int) == [1, 2]
+
+
+def test_categorical_variables_raises_error_when_no_categorical_variables():
+    msg = (
+        "No categorical variables found in this dataframe. Please check "
+        "variable format with pandas dtypes."
+    )
+    with pytest.raises(TypeError) as record:
+        assert find_categorical_variables(df.drop(["Name", "City"], axis=1))
+    assert str(record.value) == msg
+
+    with pytest.raises(TypeError) as record:
+        assert find_categorical_variables(df_int.drop([1, 2], axis=1))
+    assert str(record.value) == msg
diff --git a/tests/test_variable_handling/test_variable_selection.py b/tests/test_variable_handling/test_variable_selection.py
index 2da3046..239194b 100644
--- a/tests/test_variable_handling/test_variable_selection.py
+++ b/tests/test_variable_handling/test_variable_selection.py
@@ -5,190 +5,16 @@ from feature_engine.variable_handling.variable_selection import (
     _filter_out_variables_not_in_dataframe,
     find_all_variables,
     find_categorical_and_numerical_variables,
-    find_or_check_categorical_variables,
     find_or_check_datetime_variables,
-    find_numerical_variables,
-    check_numerical_variables,
 )
 
 
-df = pd.DataFrame({
-    "Name": ["tom", "nick", "krish", "jack"],
-    "City": ["London", "Manchester", "Liverpool", "Bristol"],
-    "Age": [20, 21, 19, 18],
-    "Marks": [0.9, 0.8, 0.7, 0.6],
-    "dob": pd.date_range("2020-02-24", periods=4, freq="T"),
-})
-
-df_int = pd.DataFrame({
-    1: ["tom", "nick", "krish", "jack"],
-    2: ["London", "Manchester", "Liverpool", "Bristol"],
-    3: [20, 21, 19, 18],
-    4: [0.9, 0.8, 0.7, 0.6],
-    5: pd.date_range("2020-02-24", periods=4, freq="T"),
-})
-
-
-def test_find_numerical_variables_finds_numerical_variables():
-    assert find_numerical_variables(df) == ["Age", "Marks"]
-    assert find_numerical_variables(df_int) == [3, 4]
-
-
-def test_find_numerical_variables_raises_error_when_no_numerical_variables():
-    msg = (
-        "No numerical variables found in this dataframe. Please check "
-        "variable format with pandas dtypes."
-           )
-    with pytest.raises(TypeError) as record:
-        assert find_numerical_variables(df.drop(["Age", "Marks"], axis=1))
-    assert str(record.value) == msg
-
-    with pytest.raises(TypeError) as record:
-        assert find_numerical_variables(df_int.drop([3, 4], axis=1))
-    assert str(record.value) == msg
-
-
-def test_check_numerical_variables_returns_numerical_variables():
-    assert check_numerical_variables(df, ["Age", "Marks"]) == ["Age", "Marks"]
-    assert check_numerical_variables(df, ["Age"]) == ["Age"]
-    assert check_numerical_variables(df, "Age") == ["Age"]
-    assert check_numerical_variables(df_int, [3, 4]) == [3, 4]
-    assert check_numerical_variables(df_int, [3]) == [3]
-    assert check_numerical_variables(df_int, 4) == [4]
-
-
-def test_check_numerical_variables_raises_errors_when_not_numerical():
-    msg = (
-        "Some of the variables are not numerical. Please cast them as "
-        "numerical before using this transformer."
-           )
-    with pytest.raises(TypeError) as record:
-        assert check_numerical_variables(df, "Name")
-    assert str(record.value) == msg
-
-    with pytest.raises(TypeError) as record:
-        assert check_numerical_variables(df, ["Name"])
-    assert str(record.value) == msg
-
-    with pytest.raises(TypeError) as record:
-        assert check_numerical_variables(df_int, 1)
-    assert str(record.value) == msg
-
-    with pytest.raises(TypeError) as record:
-        assert check_numerical_variables(df_int, [1])
-    assert str(record.value) == msg
-
-    with pytest.raises(TypeError) as record:
-        assert check_numerical_variables(df, ["Name", "Marks"])
-    assert str(record.value) == msg
-
-    with pytest.raises(TypeError) as record:
-        assert check_numerical_variables(df_int, [2, 3])
-    assert str(record.value) == msg
-
-
 def _cast_var_as_type(df, var, new_type):
     df_copy = df.copy()
     df_copy[var] = df[var].astype(new_type)
     return df_copy
 
 
-def test_find_or_check_categorical_variables(
-    df_vartypes, df_datetime, df_numeric_columns
-):
-    vars_cat = ["Name", "City"]
-    vars_mix = ["Age", "Marks", "Name"]
-
-    # errors when vars entered by user are not categorical
-    with pytest.raises(TypeError):
-        assert find_or_check_categorical_variables(df_vartypes, "Marks")
-    with pytest.raises(TypeError):
-        assert find_or_check_categorical_variables(df_datetime, "datetime_range")
-    with pytest.raises(TypeError):
-        assert find_or_check_categorical_variables(df_datetime, ["datetime_range"])
-    with pytest.raises(TypeError):
-        assert find_or_check_categorical_variables(df_numeric_columns, 3)
-    with pytest.raises(TypeError):
-        assert find_or_check_categorical_variables(df_numeric_columns, [0, 2])
-    with pytest.raises(TypeError):
-        assert find_or_check_categorical_variables(df_vartypes, vars_mix)
-
-    # error when user enters empty list
-    with pytest.raises(ValueError):
-        assert find_or_check_categorical_variables(df_vartypes, variables=[])
-
-    # error when df has no categorical variables
-    with pytest.raises(ValueError):
-        assert find_or_check_categorical_variables(df_vartypes[["Age", "Marks"]], None)
-    with pytest.raises(ValueError):
-        assert find_or_check_categorical_variables(
-            df_datetime[["date_obj1", "time_obj"]], None
-        )
-
-    # when variables=None
-    assert find_or_check_categorical_variables(df_vartypes, None) == vars_cat
-    assert find_or_check_categorical_variables(df_datetime, None) == ["Name"]
-
-    # when vars are specified
-    assert find_or_check_categorical_variables(df_vartypes, "Name") == ["Name"]
-    assert find_or_check_categorical_variables(df_datetime, "date_obj1") == [
-        "date_obj1"
-    ]
-    assert find_or_check_categorical_variables(df_vartypes, vars_cat) == vars_cat
-    assert find_or_check_categorical_variables(df_datetime, ["Name", "date_obj1"]) == [
-        "Name",
-        "date_obj1",
-    ]
-
-    # vars specified, column name is integer
-    assert find_or_check_categorical_variables(df_numeric_columns, [0, 1]) == [0, 1]
-    assert find_or_check_categorical_variables(df_numeric_columns, 0) == [0]
-    assert find_or_check_categorical_variables(df_numeric_columns, 1) == [1]
-
-    # datetime vars cast as category
-    # object-like datetime
-    df_datetime["date_obj1"] = df_datetime["date_obj1"].astype("category")
-    assert find_or_check_categorical_variables(df_datetime, None) == ["Name"]
-    assert find_or_check_categorical_variables(df_datetime, ["Name", "date_obj1"]) == [
-        "Name",
-        "date_obj1",
-    ]
-    # datetime64
-    df_datetime["datetime_range"] = df_datetime["datetime_range"].astype("category")
-    assert find_or_check_categorical_variables(df_datetime, None) == ["Name"]
-    assert find_or_check_categorical_variables(
-        df_datetime, ["Name", "datetime_range"]
-    ) == ["Name", "datetime_range"]
-
-    # time-aware datetime var
-    tz_time = pd.DataFrame(
-        {"time_objTZ": df_datetime["time_obj"].add(["+5", "+11", "-3", "-8"])}
-    )
-    with pytest.raises(ValueError):
-        assert find_or_check_categorical_variables(tz_time, None)
-    assert find_or_check_categorical_variables(tz_time, "time_objTZ") == ["time_objTZ"]
-
-
-@pytest.mark.parametrize(
-    "_num_var, _cat_type",
-    [("Age", "category"), ("Age", "O"), ("Marks", "category"), ("Marks", "O")],
-)
-def test_find_or_check_categorical_variables_when_numeric_is_cast_as_category_or_object(
-    df_vartypes, _num_var, _cat_type
-):
-    df_vartypes = _cast_var_as_type(df_vartypes, _num_var, _cat_type)
-    assert find_or_check_categorical_variables(df_vartypes, _num_var) == [_num_var]
-    assert find_or_check_categorical_variables(df_vartypes, None) == [
-        "Name",
-        "City",
-        _num_var,
-    ]
-    assert find_or_check_categorical_variables(df_vartypes, ["Name", _num_var]) == [
-        "Name",
-        _num_var,
-    ]
-
-
 def test_find_or_check_datetime_variables(df_datetime):
     var_dt = ["datetime_range"]
     var_dt_str = "datetime_range"