Repository: feature-engine/feature_engine
Pull request #715 (2023-12-26 13:03:24)

refactor find_or_check_datetime_variables

codecov[bot]: ## [Codecov](https://app.codecov.io/gh/feature-engine/feature_engine/pull/715?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=feature-engine) Report
Attention: `4 lines` in your changes are missing coverage. Please review.
> Comparison is base [(`e55c991`)](https://app.codecov.io/gh/feature-engine/feature_engine/commit/e55c9918b5247f8b68c521c6fd5c57fb8dfa4b7d?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=feature-engine) 98.00% compared to head [(`b5b2a04`)](https://app.codecov.io/gh/feature-engine/feature_engine/pull/715?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=feature-engine) 97.91%.

| [Files](https://app.codecov.io/gh/feature-engine/feature_engine/pull/715?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=feature-engine) | Patch % | Lines |
|---|---|---|
| [feature\_engine/datetime/datetime\_subtraction.py](https://app.codecov.io/gh/feature-engine/feature_engine/pull/715?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=feature-engine#diff-ZmVhdHVyZV9lbmdpbmUvZGF0ZXRpbWUvZGF0ZXRpbWVfc3VidHJhY3Rpb24ucHk=) | 55.55% | [2 Missing and 2 partials :warning: ](https://app.codecov.io/gh/feature-engine/feature_engine/pull/715?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=feature-engine) |

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


```diff
@@            Coverage Diff             @@
##             main     #715      +/-   ##
==========================================
- Coverage   98.00%   97.91%   -0.10%     
==========================================
  Files         102      102              
  Lines        3915     3925      +10     
  Branches      771      772       +1     
==========================================
+ Hits         3837     3843       +6     
- Misses         29       31       +2     
- Partials       49       51       +2     
```



</details>

[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/feature-engine/feature_engine/pull/715?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_datetime_variables.rst b/docs/api_doc/variable_handling/check_datetime_variables.rst
new file mode 100644
index 0000000..e06a290
--- /dev/null
+++ b/docs/api_doc/variable_handling/check_datetime_variables.rst
@@ -0,0 +1,6 @@
+check_datetime_variables
+========================
+
+.. currentmodule:: feature_engine.variable_handling
+
+.. autofunction:: check_datetime_variables
\ No newline at end of file
diff --git a/docs/api_doc/variable_handling/find_datetime_variables.rst b/docs/api_doc/variable_handling/find_datetime_variables.rst
new file mode 100644
index 0000000..aa5b5ea
--- /dev/null
+++ b/docs/api_doc/variable_handling/find_datetime_variables.rst
@@ -0,0 +1,6 @@
+﻿find_datetime_variables
+=======================
+
+.. currentmodule:: feature_engine.variable_handling
+
+.. autofunction:: find_datetime_variables
\ No newline at end of file
diff --git a/docs/api_doc/variable_handling/find_or_check_datetime_variables.rst b/docs/api_doc/variable_handling/find_or_check_datetime_variables.rst
deleted file mode 100644
index 53a86ce..0000000
--- a/docs/api_doc/variable_handling/find_or_check_datetime_variables.rst
+++ /dev/null
@@ -1,6 +0,0 @@
-﻿find_or_check_datetime_variables
-================================
-
-.. currentmodule:: feature_engine.variable_handling
-
-.. autofunction:: find_or_check_datetime_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 97cbad9..b8297e1 100644
--- a/docs/api_doc/variable_handling/index.rst
+++ b/docs/api_doc/variable_handling/index.rst
@@ -19,8 +19,9 @@ variables that they will modify.
 
    find_all_variables
    find_categorical_variables
+   find_datetime_variables
    find_numerical_variables
    find_categorical_and_numerical_variables
-   find_or_check_datetime_variables
    check_categorical_variables
+   check_datetime_variables
    check_numerical_variables
diff --git a/docs/user_guide/variable_handling/check_datetime_variables.rst b/docs/user_guide/variable_handling/check_datetime_variables.rst
new file mode 100644
index 0000000..2302b33
--- /dev/null
+++ b/docs/user_guide/variable_handling/check_datetime_variables.rst
@@ -0,0 +1,90 @@
+.. _check_datetime_vars:
+
+.. currentmodule:: feature_engine.variable_handling.variable_type_selection
+
+check_datetime_variables
+========================
+
+:class:`check_datetime_variables()` checks that the variables in the list are, or can
+be parsed as datetime.
+
+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
+
+The dataframe has 3 datetime variables, two of them are of type datetime and one of type
+object.
+
+Let's check that a list of variables can be parsed as datetime:
+
+.. code:: python
+
+    from feature_engine.variable_handling import check_datetime_variables
+
+    var_date = check_datetime_variables(X, ["date2", "date3"])
+
+    var_date
+
+In this case, both variables, if they can be parsed as datetime, will be in the
+resulting list:
+
+.. code:: python
+
+    ['date2', 'date3']
+
+If we pass a variable that can't be parsed as datetime, :class:`check_datetime_variables()`
+will return an error:
+
+.. code:: python
+
+    check_datetime_variables(X, ["date2", "cat_var1"])
+
+Below the error message:
+
+.. code:: python
+
+    TypeError: Some of the variables are not or cannot be parsed as datetime.
diff --git a/docs/user_guide/variable_handling/find_or_check_datetime_variables.rst b/docs/user_guide/variable_handling/find_datetime_variables.rst
similarity index 67%
rename from docs/user_guide/variable_handling/find_or_check_datetime_variables.rst
rename to docs/user_guide/variable_handling/find_datetime_variables.rst
index 1d752e0..f657928 100644
--- a/docs/user_guide/variable_handling/find_or_check_datetime_variables.rst
+++ b/docs/user_guide/variable_handling/find_datetime_variables.rst
@@ -2,10 +2,10 @@
 
 .. currentmodule:: feature_engine.variable_handling.variable_type_selection
 
-find_or_check_datetime_variables
-================================
+find_datetime_variables
+=======================
 
-With :class:`find_or_check_datetime_variables()` you can automatically capture in a list
+With :class:`find_datetime_variables()` you can automatically capture in a list
 the names of all datetime variables in a dataset, whether they are parsed as datetime
 or object.
 
@@ -60,14 +60,14 @@ We see the resulting dataframe below:
 The dataframe has 3 datetime variables, two of them are of type datetime and one of type
 object.
 
-We can now use :class:`find_or_check_datetime_variables()` to capture all datetime variables
+We can now use :class:`find_datetime_variables()` to capture all datetime variables
 regardless of their data type. So let's do that and then display the list:
 
 .. code:: python
 
-    from feature_engine.variable_handling import find_or_check_datetime_variables
+    from feature_engine.variable_handling import find_datetime_variables
 
-    var_date = find_or_check_datetime_variables(X)
+    var_date = find_datetime_variables(X)
 
     var_date
 
@@ -77,33 +77,6 @@ Below we see the variable names in the list:
 
     ['date1', 'date2', 'date3']
 
-Note that :class:`find_or_check_datetime_variables()` captures all 3 datetime variables.
+Note that :class:`find_datetime_variables()` captures all 3 datetime variables.
 The first 2 are of type datetime, whereas the third variable is of type object. But as it
-can be parsed as datetime, it will be captured in the list as well.
-
-We can also corroborate that a list of variables can be parsed as datetime as follows:
-
-.. code:: python
-
-    var_date = find_or_check_datetime_variables(X, ["date2", "date3"])
-
-    var_date
-
-In this case, both variables, if they can be parsed as datetime, will be in the resulting list:
-
-.. code:: python
-
-    ['date2', 'date3']
-
-If we pass a variable that can't be parsed as datetime, :class:`find_or_check_datetime_variables()`
-will return an error:
-
-.. code:: python
-
-    find_or_check_datetime_variables(X, ["date2", "cat_var1"])
-
-Below the error message:
-
-.. code:: python
-
-    TypeError: Some of the variables are not datetime.
\ No newline at end of file
+can be parsed as datetime, it will be captured in the list as well.
\ 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 0b65817..1f9fc74 100644
--- a/docs/user_guide/variable_handling/index.rst
+++ b/docs/user_guide/variable_handling/index.rst
@@ -21,8 +21,9 @@ Feature-engine or Scikit-learn compatible transformers.
 
    find_all_variables
    find_categorical_variables
+   find_datetime_variables
    find_numerical_variables
    find_categorical_and_numerical_variables
-   find_or_check_datetime_variables
    check_categorical_variables
+   check_datetime_variables
    check_numerical_variables
diff --git a/feature_engine/_base_transformers/base_numerical.py b/feature_engine/_base_transformers/base_numerical.py
index 2158ae1..9c1967b 100644
--- a/feature_engine/_base_transformers/base_numerical.py
+++ b/feature_engine/_base_transformers/base_numerical.py
@@ -16,8 +16,8 @@ from feature_engine.dataframe_checks import (
 )
 from feature_engine.tags import _return_tags
 from feature_engine.variable_handling import (
-    find_numerical_variables,
     check_numerical_variables,
+    find_numerical_variables,
 )
 
 
diff --git a/feature_engine/_prediction/base_predictor.py b/feature_engine/_prediction/base_predictor.py
index c0dbccf..fc5c9a1 100644
--- a/feature_engine/_prediction/base_predictor.py
+++ b/feature_engine/_prediction/base_predictor.py
@@ -6,6 +6,9 @@ from sklearn.base import BaseEstimator
 from sklearn.pipeline import Pipeline
 from sklearn.utils.validation import check_is_fitted
 
+from feature_engine._check_init_parameters.check_variables import (
+    _check_variables_input_value,
+)
 from feature_engine.dataframe_checks import (
     _check_contains_inf,
     _check_contains_na,
@@ -19,9 +22,6 @@ from feature_engine.discretisation import (
 )
 from feature_engine.encoding import MeanEncoder
 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 (
     find_categorical_and_numerical_variables,
 )
diff --git a/feature_engine/creation/base_creation.py b/feature_engine/creation/base_creation.py
index 8a61573..7e6a501 100644
--- a/feature_engine/creation/base_creation.py
+++ b/feature_engine/creation/base_creation.py
@@ -17,8 +17,8 @@ from feature_engine.dataframe_checks import (
 )
 from feature_engine.tags import _return_tags
 from feature_engine.variable_handling import (
-    find_numerical_variables,
     check_numerical_variables,
+    find_numerical_variables,
 )
 
 
diff --git a/feature_engine/creation/cyclical_features.py b/feature_engine/creation/cyclical_features.py
index a00a41b..40e96ca 100644
--- a/feature_engine/creation/cyclical_features.py
+++ b/feature_engine/creation/cyclical_features.py
@@ -11,12 +11,12 @@ from feature_engine._base_transformers.mixins import (
 from feature_engine._check_init_parameters.check_init_input_params import (
     _check_param_drop_original,
 )
-from feature_engine._check_init_parameters.check_variables import (
-    _check_variables_input_value,
-)
 from feature_engine._check_init_parameters.check_input_dictionary import (
     _check_numerical_dict,
 )
+from feature_engine._check_init_parameters.check_variables import (
+    _check_variables_input_value,
+)
 from feature_engine._docstrings.fit_attributes import (
     _feature_names_in_docstring,
     _n_features_in_docstring,
diff --git a/feature_engine/datetime/datetime.py b/feature_engine/datetime/datetime.py
index c1019ca..bd158ae 100644
--- a/feature_engine/datetime/datetime.py
+++ b/feature_engine/datetime/datetime.py
@@ -9,6 +9,9 @@ from sklearn.base import BaseEstimator, TransformerMixin
 from sklearn.utils.validation import check_is_fitted
 
 from feature_engine._base_transformers.mixins import GetFeatureNamesOutMixin
+from feature_engine._check_init_parameters.check_variables import (
+    _check_variables_input_value,
+)
 from feature_engine._docstrings.fit_attributes import (
     _feature_names_in_docstring,
     _n_features_in_docstring,
@@ -29,15 +32,11 @@ from feature_engine.datetime._datetime_constants import (
     FEATURES_SUFFIXES,
     FEATURES_SUPPORTED,
 )
-from feature_engine._check_init_parameters.check_variables import (
-    _check_variables_input_value,
-)
 from feature_engine.variable_handling._variable_type_checks import (
     _is_categorical_and_is_datetime,
 )
-from feature_engine.variable_handling.variable_selection import (
-    find_or_check_datetime_variables,
-)
+from feature_engine.variable_handling.check_variables import check_datetime_variables
+from feature_engine.variable_handling.find_variables import find_datetime_variables
 
 
 @Substitution(
@@ -258,17 +257,19 @@ class DatetimeFeatures(BaseEstimator, TransformerMixin, GetFeatureNamesOutMixin)
             ):
                 raise TypeError("The dataframe index is not datetime.")
 
-            if self.missing_values == "raise":
-                self._check_index_contains_na(X.index)
+            self.variables_ = []
 
-            self.variables_ = None
+        elif self.variables is None:
+            self.variables_ = find_datetime_variables(X)
 
         else:
-            # find or check for datetime variables
-            self.variables_ = find_or_check_datetime_variables(X, self.variables)
+            self.variables_ = check_datetime_variables(X, self.variables)
 
-            # check if datetime variables contains na
-            if self.missing_values == "raise":
+        # check if datetime variables contains na
+        if self.missing_values == "raise":
+            if self.variables == "index":
+                self._check_index_contains_na(X.index)
+            else:
                 _check_contains_na(X, self.variables_)
 
         if self.features_to_extract is None:
@@ -314,7 +315,7 @@ class DatetimeFeatures(BaseEstimator, TransformerMixin, GetFeatureNamesOutMixin)
         X = X[self.feature_names_in_]
 
         # special case index
-        if self.variables_ is None:
+        if self.variables == "index":
             # check if dataset contains na
             if self.missing_values == "raise":
                 self._check_index_contains_na(X.index)
@@ -376,7 +377,7 @@ class DatetimeFeatures(BaseEstimator, TransformerMixin, GetFeatureNamesOutMixin)
         else:
             feature_names = [
                 str(var) + FEATURES_SUFFIXES[feat]
-                for var in self.variables_  # type: ignore
+                for var in self.variables_
                 for feat in self.features_to_extract_
             ]
 
diff --git a/feature_engine/datetime/datetime_subtraction.py b/feature_engine/datetime/datetime_subtraction.py
index f2a0b16..cd4472c 100644
--- a/feature_engine/datetime/datetime_subtraction.py
+++ b/feature_engine/datetime/datetime_subtraction.py
@@ -5,6 +5,9 @@ import pandas as pd
 from pandas.api.types import is_datetime64_any_dtype as is_datetime
 from sklearn.utils.validation import check_is_fitted
 
+from feature_engine._check_init_parameters.check_variables import (
+    _check_variables_input_value,
+)
 from feature_engine._docstrings.fit_attributes import (
     _feature_names_in_docstring,
     _n_features_in_docstring,
@@ -24,10 +27,8 @@ from feature_engine.dataframe_checks import (
     _check_X_matches_training_df,
     check_X,
 )
-from feature_engine.variable_handling import find_or_check_datetime_variables
-from feature_engine._check_init_parameters.check_variables import (
-    _check_variables_input_value,
-)
+from feature_engine.variable_handling.check_variables import check_datetime_variables
+from feature_engine.variable_handling.find_variables import find_datetime_variables
 
 _example = """
     >>> import pandas as pd
@@ -151,8 +152,8 @@ class DatetimeSubtraction(BaseCreation):
 
     def __init__(
         self,
-        variables: Union[None, int, str, List[Union[str, int]]],
-        reference: Union[None, int, str, List[Union[str, int]]],
+        variables: Union[None, int, str, List[Union[str, int]]] = None,
+        reference: Union[None, int, str, List[Union[str, int]]] = None,
         new_variables_names: Union[None, List[str], str] = None,
         output_unit: str = "D",
         missing_values: str = "ignore",
@@ -224,8 +225,15 @@ class DatetimeSubtraction(BaseCreation):
         X = check_X(X)
 
         # check variables are datetime
-        self.reference_ = find_or_check_datetime_variables(X, self.reference)
-        self.variables_ = find_or_check_datetime_variables(X, self.variables)
+        if self.variables is None:
+            self.variables_ = find_datetime_variables(X)
+        else:
+            self.variables_ = check_datetime_variables(X, self.variables)
+
+        if self.reference is None:
+            self.reference_ = find_datetime_variables(X)
+        else:
+            self.reference_ = check_datetime_variables(X, self.reference)
 
         if self.new_variables_names is not None:
             if len(self.new_variables_names) != len(self.variables_) * len(
@@ -240,7 +248,8 @@ class DatetimeSubtraction(BaseCreation):
 
         # check if dataset contains na
         if self.missing_values == "raise":
-            _check_contains_na(X, self.variables_ + self.reference_)
+            vars = list(set(self.variables_ + self.reference_))
+            _check_contains_na(X, vars)
 
         # save input features
         self.feature_names_in_ = X.columns.tolist()
@@ -275,7 +284,8 @@ class DatetimeSubtraction(BaseCreation):
         _check_X_matches_training_df(X, self.n_features_in_)
 
         if self.missing_values == "raise":
-            _check_contains_na(X, self.variables_ + self.reference_)
+            vars = list(set(self.variables_ + self.reference_))
+            _check_contains_na(X, vars)
 
         # reorder variables to match train set
         X = X[self.feature_names_in_]
diff --git a/feature_engine/discretisation/decision_tree.py b/feature_engine/discretisation/decision_tree.py
index a417f3a..decef6a 100644
--- a/feature_engine/discretisation/decision_tree.py
+++ b/feature_engine/discretisation/decision_tree.py
@@ -9,6 +9,9 @@ from sklearn.tree import DecisionTreeClassifier, DecisionTreeRegressor
 from sklearn.utils.multiclass import check_classification_targets, type_of_target
 
 from feature_engine._base_transformers.base_numerical import BaseNumericalTransformer
+from feature_engine._check_init_parameters.check_variables import (
+    _check_variables_input_value,
+)
 from feature_engine._docstrings.fit_attributes import (
     _feature_names_in_docstring,
     _n_features_in_docstring,
@@ -20,9 +23,6 @@ from feature_engine._docstrings.init_parameters.all_trasnformers import (
 from feature_engine._docstrings.methods import _fit_transform_docstring
 from feature_engine._docstrings.substitute import Substitution
 from feature_engine.tags import _return_tags
-from feature_engine._check_init_parameters.check_variables import (
-    _check_variables_input_value,
-)
 
 
 @Substitution(
diff --git a/feature_engine/discretisation/equal_frequency.py b/feature_engine/discretisation/equal_frequency.py
index 54e7d36..9060f1d 100644
--- a/feature_engine/discretisation/equal_frequency.py
+++ b/feature_engine/discretisation/equal_frequency.py
@@ -5,6 +5,9 @@ from typing import List, Optional, Union
 
 import pandas as pd
 
+from feature_engine._check_init_parameters.check_variables import (
+    _check_variables_input_value,
+)
 from feature_engine._docstrings.fit_attributes import (
     _binner_dict_docstring,
     _feature_names_in_docstring,
@@ -26,9 +29,6 @@ from feature_engine._docstrings.methods import (
 )
 from feature_engine._docstrings.substitute import Substitution
 from feature_engine.discretisation.base_discretiser import BaseDiscretiser
-from feature_engine._check_init_parameters.check_variables import (
-    _check_variables_input_value,
-)
 
 
 @Substitution(
diff --git a/feature_engine/discretisation/equal_width.py b/feature_engine/discretisation/equal_width.py
index 07a3481..0378783 100644
--- a/feature_engine/discretisation/equal_width.py
+++ b/feature_engine/discretisation/equal_width.py
@@ -5,6 +5,9 @@ from typing import List, Optional, Union
 
 import pandas as pd
 
+from feature_engine._check_init_parameters.check_variables import (
+    _check_variables_input_value,
+)
 from feature_engine._docstrings.fit_attributes import (
     _binner_dict_docstring,
     _feature_names_in_docstring,
@@ -26,9 +29,6 @@ from feature_engine._docstrings.methods import (
 )
 from feature_engine._docstrings.substitute import Substitution
 from feature_engine.discretisation.base_discretiser import BaseDiscretiser
-from feature_engine._check_init_parameters.check_variables import (
-    _check_variables_input_value,
-)
 
 
 @Substitution(
diff --git a/feature_engine/discretisation/geometric_width.py b/feature_engine/discretisation/geometric_width.py
index 0e015dd..9f7c37d 100644
--- a/feature_engine/discretisation/geometric_width.py
+++ b/feature_engine/discretisation/geometric_width.py
@@ -3,6 +3,9 @@ from typing import List, Optional, Union
 import numpy as np
 import pandas as pd
 
+from feature_engine._check_init_parameters.check_variables import (
+    _check_variables_input_value,
+)
 from feature_engine._docstrings.fit_attributes import (
     _binner_dict_docstring,
     _feature_names_in_docstring,
@@ -23,9 +26,6 @@ from feature_engine._docstrings.methods import (
     _transform_discretiser_docstring,
 )
 from feature_engine._docstrings.substitute import Substitution
-from feature_engine._check_init_parameters.check_variables import (
-    _check_variables_input_value,
-)
 from feature_engine.discretisation.base_discretiser import BaseDiscretiser
 
 
diff --git a/feature_engine/encoding/base_encoder.py b/feature_engine/encoding/base_encoder.py
index 1b7025e..993a057 100644
--- a/feature_engine/encoding/base_encoder.py
+++ b/feature_engine/encoding/base_encoder.py
@@ -6,6 +6,9 @@ from sklearn.base import BaseEstimator, TransformerMixin
 from sklearn.utils.validation import check_is_fitted
 
 from feature_engine._base_transformers.mixins import GetFeatureNamesOutMixin
+from feature_engine._check_init_parameters.check_variables import (
+    _check_variables_input_value,
+)
 from feature_engine._docstrings.init_parameters.all_trasnformers import (
     _missing_values_docstring,
     _variables_categorical_docstring,
@@ -18,13 +21,10 @@ from feature_engine.dataframe_checks import (
     check_X,
 )
 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 import (
+    check_categorical_variables,
     find_all_variables,
     find_categorical_variables,
-    check_categorical_variables,
 )
 
 
diff --git a/feature_engine/imputation/arbitrary_number.py b/feature_engine/imputation/arbitrary_number.py
index 2ea30f7..668f391 100644
--- a/feature_engine/imputation/arbitrary_number.py
+++ b/feature_engine/imputation/arbitrary_number.py
@@ -8,6 +8,9 @@ import pandas as pd
 from feature_engine._check_init_parameters.check_input_dictionary import (
     _check_numerical_dict,
 )
+from feature_engine._check_init_parameters.check_variables import (
+    _check_variables_input_value,
+)
 from feature_engine._docstrings.fit_attributes import (
     _feature_names_in_docstring,
     _imputer_dict_docstring,
@@ -22,12 +25,9 @@ from feature_engine._docstrings.methods import (
 from feature_engine._docstrings.substitute import Substitution
 from feature_engine.dataframe_checks import check_X
 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 import (
-    find_numerical_variables,
     check_numerical_variables,
+    find_numerical_variables,
 )
 
 
diff --git a/feature_engine/imputation/categorical.py b/feature_engine/imputation/categorical.py
index 4542bf5..8a12ac6 100644
--- a/feature_engine/imputation/categorical.py
+++ b/feature_engine/imputation/categorical.py
@@ -5,6 +5,9 @@ from typing import List, Optional, Union
 
 import pandas as pd
 
+from feature_engine._check_init_parameters.check_variables import (
+    _check_variables_input_value,
+)
 from feature_engine._docstrings.fit_attributes import (
     _feature_names_in_docstring,
     _imputer_dict_docstring,
@@ -19,13 +22,10 @@ from feature_engine._docstrings.substitute import Substitution
 from feature_engine.dataframe_checks import check_X
 from feature_engine.imputation.base_imputer import BaseImputer
 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 import (
+    check_categorical_variables,
     find_all_variables,
     find_categorical_variables,
-    check_categorical_variables,
 )
 
 
diff --git a/feature_engine/imputation/drop_missing_data.py b/feature_engine/imputation/drop_missing_data.py
index bcd8b4a..23ea299 100644
--- a/feature_engine/imputation/drop_missing_data.py
+++ b/feature_engine/imputation/drop_missing_data.py
@@ -5,6 +5,9 @@ from typing import List, Optional, Union
 
 import pandas as pd
 
+from feature_engine._check_init_parameters.check_variables import (
+    _check_variables_input_value,
+)
 from feature_engine._docstrings.fit_attributes import (
     _feature_names_in_docstring,
     _n_features_in_docstring,
@@ -14,9 +17,6 @@ from feature_engine._docstrings.substitute import Substitution
 from feature_engine.dataframe_checks import check_X
 from feature_engine.imputation.base_imputer import BaseImputer
 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 find_all_variables
 
 
diff --git a/feature_engine/imputation/end_tail.py b/feature_engine/imputation/end_tail.py
index 3b39448..59e59f3 100644
--- a/feature_engine/imputation/end_tail.py
+++ b/feature_engine/imputation/end_tail.py
@@ -5,6 +5,9 @@ from typing import List, Optional, Union
 
 import pandas as pd
 
+from feature_engine._check_init_parameters.check_variables import (
+    _check_variables_input_value,
+)
 from feature_engine._docstrings.fit_attributes import (
     _feature_names_in_docstring,
     _imputer_dict_docstring,
@@ -21,12 +24,9 @@ from feature_engine._docstrings.methods import (
 from feature_engine._docstrings.substitute import Substitution
 from feature_engine.dataframe_checks import check_X
 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 import (
-    find_numerical_variables,
     check_numerical_variables,
+    find_numerical_variables,
 )
 
 
diff --git a/feature_engine/imputation/mean_median.py b/feature_engine/imputation/mean_median.py
index 5c54dad..da845e0 100644
--- a/feature_engine/imputation/mean_median.py
+++ b/feature_engine/imputation/mean_median.py
@@ -5,6 +5,9 @@ from typing import List, Optional, Union
 
 import pandas as pd
 
+from feature_engine._check_init_parameters.check_variables import (
+    _check_variables_input_value,
+)
 from feature_engine._docstrings.fit_attributes import (
     _feature_names_in_docstring,
     _imputer_dict_docstring,
@@ -21,12 +24,9 @@ from feature_engine._docstrings.methods import (
 from feature_engine._docstrings.substitute import Substitution
 from feature_engine.dataframe_checks import check_X
 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 import (
-    find_numerical_variables,
     check_numerical_variables,
+    find_numerical_variables,
 )
 
 
diff --git a/feature_engine/imputation/missing_indicator.py b/feature_engine/imputation/missing_indicator.py
index cab7e19..10f70e2 100644
--- a/feature_engine/imputation/missing_indicator.py
+++ b/feature_engine/imputation/missing_indicator.py
@@ -5,6 +5,9 @@ from typing import List, Optional, Union
 
 import pandas as pd
 
+from feature_engine._check_init_parameters.check_variables import (
+    _check_variables_input_value,
+)
 from feature_engine._docstrings.fit_attributes import (
     _feature_names_in_docstring,
     _n_features_in_docstring,
@@ -14,9 +17,6 @@ from feature_engine._docstrings.substitute import Substitution
 from feature_engine.dataframe_checks import check_X
 from feature_engine.imputation.base_imputer import BaseImputer
 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 find_all_variables
 
 
diff --git a/feature_engine/imputation/random_sample.py b/feature_engine/imputation/random_sample.py
index 24c741c..7ae1c6f 100644
--- a/feature_engine/imputation/random_sample.py
+++ b/feature_engine/imputation/random_sample.py
@@ -6,6 +6,9 @@ from typing import List, Optional, Union
 import numpy as np
 import pandas as pd
 
+from feature_engine._check_init_parameters.check_variables import (
+    _check_variables_input_value,
+)
 from feature_engine._docstrings.fit_attributes import (
     _feature_names_in_docstring,
     _n_features_in_docstring,
@@ -19,9 +22,6 @@ from feature_engine._docstrings.substitute import Substitution
 from feature_engine.dataframe_checks import check_X
 from feature_engine.imputation.base_imputer import BaseImputer
 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 find_all_variables
 
 
diff --git a/feature_engine/outliers/base_outlier.py b/feature_engine/outliers/base_outlier.py
index 504a127..ea4e962 100644
--- a/feature_engine/outliers/base_outlier.py
+++ b/feature_engine/outliers/base_outlier.py
@@ -5,6 +5,9 @@ from sklearn.base import BaseEstimator, TransformerMixin
 from sklearn.utils.validation import check_is_fitted
 
 from feature_engine._base_transformers.mixins import GetFeatureNamesOutMixin
+from feature_engine._check_init_parameters.check_variables import (
+    _check_variables_input_value,
+)
 from feature_engine.dataframe_checks import (
     _check_contains_inf,
     _check_contains_na,
@@ -12,12 +15,9 @@ from feature_engine.dataframe_checks import (
     check_X,
 )
 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 import (
-    find_numerical_variables,
     check_numerical_variables,
+    find_numerical_variables,
 )
 
 
diff --git a/feature_engine/preprocessing/match_columns.py b/feature_engine/preprocessing/match_columns.py
index 7b74ab3..1b6099b 100644
--- a/feature_engine/preprocessing/match_columns.py
+++ b/feature_engine/preprocessing/match_columns.py
@@ -1,4 +1,4 @@
-from typing import List, Dict, Union
+from typing import Dict, List, Union
 
 import numpy as np
 import pandas as pd
diff --git a/feature_engine/selection/base_recursive_selector.py b/feature_engine/selection/base_recursive_selector.py
index 1029c1c..12ffbbd 100644
--- a/feature_engine/selection/base_recursive_selector.py
+++ b/feature_engine/selection/base_recursive_selector.py
@@ -3,15 +3,15 @@ from typing import List, Union
 import pandas as pd
 from sklearn.model_selection import cross_validate
 
-from feature_engine.dataframe_checks import check_X_y
-from feature_engine.selection.base_selector import BaseSelector, get_feature_importances
-from feature_engine.tags import _return_tags
 from feature_engine._check_init_parameters.check_variables import (
     _check_variables_input_value,
 )
+from feature_engine.dataframe_checks import check_X_y
+from feature_engine.selection.base_selector import BaseSelector, get_feature_importances
+from feature_engine.tags import _return_tags
 from feature_engine.variable_handling import (
-    find_numerical_variables,
     check_numerical_variables,
+    find_numerical_variables,
 )
 
 Variables = Union[None, int, str, List[Union[str, int]]]
diff --git a/feature_engine/selection/drop_constant_features.py b/feature_engine/selection/drop_constant_features.py
index e0fd3ea..8de3315 100644
--- a/feature_engine/selection/drop_constant_features.py
+++ b/feature_engine/selection/drop_constant_features.py
@@ -2,6 +2,9 @@ from typing import List, Union
 
 import pandas as pd
 
+from feature_engine._check_init_parameters.check_variables import (
+    _check_variables_input_value,
+)
 from feature_engine._docstrings.fit_attributes import (
     _feature_names_in_docstring,
     _n_features_in_docstring,
@@ -10,18 +13,15 @@ from feature_engine._docstrings.init_parameters.selection import (
     _confirm_variables_docstring,
 )
 from feature_engine._docstrings.methods import _fit_transform_docstring
-from feature_engine._docstrings.substitute import Substitution
-from feature_engine.dataframe_checks import _check_contains_na, check_X
 from feature_engine._docstrings.selection._docstring import (
     _get_support_docstring,
     _variables_all_docstring,
     _variables_attribute_docstring,
 )
+from feature_engine._docstrings.substitute import Substitution
+from feature_engine.dataframe_checks import _check_contains_na, check_X
 from feature_engine.selection.base_selector import BaseSelector
 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 find_all_variables
 
 Variables = Union[None, int, str, List[Union[str, int]]]
diff --git a/feature_engine/selection/drop_correlated_features.py b/feature_engine/selection/drop_correlated_features.py
index 0bc0342..8130aea 100644
--- a/feature_engine/selection/drop_correlated_features.py
+++ b/feature_engine/selection/drop_correlated_features.py
@@ -2,6 +2,9 @@ from typing import List, Union
 
 import pandas as pd
 
+from feature_engine._check_init_parameters.check_variables import (
+    _check_variables_input_value,
+)
 from feature_engine._docstrings.fit_attributes import (
     _feature_names_in_docstring,
     _n_features_in_docstring,
@@ -10,25 +13,22 @@ from feature_engine._docstrings.init_parameters.selection import (
     _confirm_variables_docstring,
 )
 from feature_engine._docstrings.methods import _fit_transform_docstring
-from feature_engine._docstrings.substitute import Substitution
-from feature_engine.dataframe_checks import (
-    _check_contains_inf,
-    _check_contains_na,
-    check_X,
-)
 from feature_engine._docstrings.selection._docstring import (
     _get_support_docstring,
     _missing_values_docstring,
     _variables_attribute_docstring,
     _variables_numerical_docstring,
 )
-from feature_engine.selection.base_selector import BaseSelector
-from feature_engine._check_init_parameters.check_variables import (
-    _check_variables_input_value,
+from feature_engine._docstrings.substitute import Substitution
+from feature_engine.dataframe_checks import (
+    _check_contains_inf,
+    _check_contains_na,
+    check_X,
 )
+from feature_engine.selection.base_selector import BaseSelector
 from feature_engine.variable_handling import (
-    find_numerical_variables,
     check_numerical_variables,
+    find_numerical_variables,
 )
 
 Variables = Union[None, int, str, List[Union[str, int]]]
diff --git a/feature_engine/selection/drop_duplicate_features.py b/feature_engine/selection/drop_duplicate_features.py
index d996178..255f000 100644
--- a/feature_engine/selection/drop_duplicate_features.py
+++ b/feature_engine/selection/drop_duplicate_features.py
@@ -3,6 +3,9 @@ from typing import List, Union
 
 import pandas as pd
 
+from feature_engine._check_init_parameters.check_variables import (
+    _check_variables_input_value,
+)
 from feature_engine._docstrings.fit_attributes import (
     _feature_names_in_docstring,
     _n_features_in_docstring,
@@ -11,19 +14,16 @@ from feature_engine._docstrings.init_parameters.selection import (
     _confirm_variables_docstring,
 )
 from feature_engine._docstrings.methods import _fit_transform_docstring
-from feature_engine._docstrings.substitute import Substitution
-from feature_engine.dataframe_checks import _check_contains_na, check_X
 from feature_engine._docstrings.selection._docstring import (
     _get_support_docstring,
     _missing_values_docstring,
     _variables_all_docstring,
     _variables_attribute_docstring,
 )
+from feature_engine._docstrings.substitute import Substitution
+from feature_engine.dataframe_checks import _check_contains_na, check_X
 from feature_engine.selection.base_selector import BaseSelector
 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 find_all_variables
 
 Variables = Union[None, int, str, List[Union[str, int]]]
diff --git a/feature_engine/selection/drop_psi_features.py b/feature_engine/selection/drop_psi_features.py
index d97a2db..5d73e6d 100644
--- a/feature_engine/selection/drop_psi_features.py
+++ b/feature_engine/selection/drop_psi_features.py
@@ -6,6 +6,9 @@ import pandas as pd
 import scipy.stats as stats
 from pandas.api.types import is_numeric_dtype
 
+from feature_engine._check_init_parameters.check_variables import (
+    _check_variables_input_value,
+)
 from feature_engine._docstrings.fit_attributes import (
     _feature_names_in_docstring,
     _n_features_in_docstring,
@@ -14,6 +17,10 @@ from feature_engine._docstrings.init_parameters.selection import (
     _confirm_variables_docstring,
 )
 from feature_engine._docstrings.methods import _fit_transform_docstring
+from feature_engine._docstrings.selection._docstring import (
+    _get_support_docstring,
+    _variables_attribute_docstring,
+)
 from feature_engine._docstrings.substitute import Substitution
 from feature_engine.dataframe_checks import (
     _check_contains_inf,
@@ -24,15 +31,8 @@ from feature_engine.discretisation import (
     EqualFrequencyDiscretiser,
     EqualWidthDiscretiser,
 )
-from feature_engine._docstrings.selection._docstring import (
-    _get_support_docstring,
-    _variables_attribute_docstring,
-)
 from feature_engine.selection.base_selector import BaseSelector
 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 (
     find_categorical_and_numerical_variables,
 )
diff --git a/feature_engine/selection/information_value.py b/feature_engine/selection/information_value.py
index 85e10d4..3aaf37b 100644
--- a/feature_engine/selection/information_value.py
+++ b/feature_engine/selection/information_value.py
@@ -3,6 +3,9 @@ from typing import List, Union
 import numpy as np
 import pandas as pd
 
+from feature_engine._check_init_parameters.check_variables import (
+    _check_variables_input_value,
+)
 from feature_engine._docstrings.fit_attributes import (
     _feature_names_in_docstring,
     _n_features_in_docstring,
@@ -13,6 +16,11 @@ from feature_engine._docstrings.init_parameters.selection import (
     _confirm_variables_docstring,
 )
 from feature_engine._docstrings.methods import _fit_transform_docstring
+from feature_engine._docstrings.selection._docstring import (
+    _features_to_drop_docstring,
+    _get_support_docstring,
+    _threshold_docstring,
+)
 from feature_engine._docstrings.substitute import Substitution
 from feature_engine.dataframe_checks import _check_contains_inf, _check_contains_na
 from feature_engine.discretisation import (
@@ -20,16 +28,8 @@ from feature_engine.discretisation import (
     EqualWidthDiscretiser,
 )
 from feature_engine.encoding.woe import WoE
-from feature_engine._docstrings.selection._docstring import (
-    _features_to_drop_docstring,
-    _get_support_docstring,
-    _threshold_docstring,
-)
 from feature_engine.selection.base_selector import BaseSelector
 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 (
     find_all_variables,
     find_categorical_and_numerical_variables,
diff --git a/feature_engine/selection/probe_feature_selection.py b/feature_engine/selection/probe_feature_selection.py
index 2ccffb4..46d186d 100644
--- a/feature_engine/selection/probe_feature_selection.py
+++ b/feature_engine/selection/probe_feature_selection.py
@@ -13,8 +13,6 @@ from feature_engine._docstrings.init_parameters.selection import (
     _estimator_docstring,
 )
 from feature_engine._docstrings.methods import _fit_transform_docstring
-from feature_engine._docstrings.substitute import Substitution
-from feature_engine.dataframe_checks import check_X_y
 from feature_engine._docstrings.selection._docstring import (
     _cv_docstring,
     _features_to_drop_docstring,
@@ -25,11 +23,13 @@ from feature_engine._docstrings.selection._docstring import (
     _variables_attribute_docstring,
     _variables_numerical_docstring,
 )
+from feature_engine._docstrings.substitute import Substitution
+from feature_engine.dataframe_checks import check_X_y
 from feature_engine.selection.base_selector import BaseSelector, get_feature_importances
 from feature_engine.tags import _return_tags
 from feature_engine.variable_handling import (
-    find_numerical_variables,
     check_numerical_variables,
+    find_numerical_variables,
 )
 
 Variables = Union[None, int, str, List[Union[str, int]]]
diff --git a/feature_engine/selection/recursive_feature_addition.py b/feature_engine/selection/recursive_feature_addition.py
index 59ed4e8..6ceab91 100644
--- a/feature_engine/selection/recursive_feature_addition.py
+++ b/feature_engine/selection/recursive_feature_addition.py
@@ -12,7 +12,6 @@ from feature_engine._docstrings.init_parameters.selection import (
     _estimator_docstring,
 )
 from feature_engine._docstrings.methods import _fit_transform_docstring
-from feature_engine._docstrings.substitute import Substitution
 from feature_engine._docstrings.selection._docstring import (
     _cv_docstring,
     _features_to_drop_docstring,
@@ -25,6 +24,7 @@ from feature_engine._docstrings.selection._docstring import (
     _variables_attribute_docstring,
     _variables_numerical_docstring,
 )
+from feature_engine._docstrings.substitute import Substitution
 from feature_engine.selection.base_recursive_selector import BaseRecursiveSelector
 
 
diff --git a/feature_engine/selection/recursive_feature_elimination.py b/feature_engine/selection/recursive_feature_elimination.py
index ed8ea6f..36f873c 100644
--- a/feature_engine/selection/recursive_feature_elimination.py
+++ b/feature_engine/selection/recursive_feature_elimination.py
@@ -12,7 +12,6 @@ from feature_engine._docstrings.init_parameters.selection import (
     _estimator_docstring,
 )
 from feature_engine._docstrings.methods import _fit_transform_docstring
-from feature_engine._docstrings.substitute import Substitution
 from feature_engine._docstrings.selection._docstring import (
     _cv_docstring,
     _features_to_drop_docstring,
@@ -25,6 +24,7 @@ from feature_engine._docstrings.selection._docstring import (
     _variables_attribute_docstring,
     _variables_numerical_docstring,
 )
+from feature_engine._docstrings.substitute import Substitution
 from feature_engine.selection.base_recursive_selector import BaseRecursiveSelector
 
 
diff --git a/feature_engine/selection/shuffle_features.py b/feature_engine/selection/shuffle_features.py
index 1f42112..a724d29 100644
--- a/feature_engine/selection/shuffle_features.py
+++ b/feature_engine/selection/shuffle_features.py
@@ -1,12 +1,15 @@
-from typing import List, Union, MutableSequence
+from typing import List, MutableSequence, Union
 
 import numpy as np
 import pandas as pd
 from sklearn.base import is_classifier
 from sklearn.metrics import get_scorer
 from sklearn.model_selection import check_cv, cross_validate
-from sklearn.utils.validation import check_random_state, _check_sample_weight
+from sklearn.utils.validation import _check_sample_weight, check_random_state
 
+from feature_engine._check_init_parameters.check_variables import (
+    _check_variables_input_value,
+)
 from feature_engine._docstrings.fit_attributes import (
     _feature_names_in_docstring,
     _n_features_in_docstring,
@@ -15,8 +18,6 @@ from feature_engine._docstrings.init_parameters.selection import (
     _confirm_variables_docstring,
 )
 from feature_engine._docstrings.methods import _fit_transform_docstring
-from feature_engine._docstrings.substitute import Substitution
-from feature_engine.dataframe_checks import check_X_y
 from feature_engine._docstrings.selection._docstring import (
     _cv_docstring,
     _estimator_docstring,
@@ -30,14 +31,13 @@ from feature_engine._docstrings.selection._docstring import (
     _variables_attribute_docstring,
     _variables_numerical_docstring,
 )
+from feature_engine._docstrings.substitute import Substitution
+from feature_engine.dataframe_checks import check_X_y
 from feature_engine.selection.base_selector import BaseSelector
 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 import (
-    find_numerical_variables,
     check_numerical_variables,
+    find_numerical_variables,
 )
 
 Variables = Union[None, int, str, List[Union[str, int]]]
diff --git a/feature_engine/selection/single_feature_performance.py b/feature_engine/selection/single_feature_performance.py
index 8c40c17..42d2d04 100644
--- a/feature_engine/selection/single_feature_performance.py
+++ b/feature_engine/selection/single_feature_performance.py
@@ -4,6 +4,9 @@ from typing import List, Union
 import pandas as pd
 from sklearn.model_selection import cross_validate
 
+from feature_engine._check_init_parameters.check_variables import (
+    _check_variables_input_value,
+)
 from feature_engine._docstrings.fit_attributes import (
     _feature_names_in_docstring,
     _n_features_in_docstring,
@@ -12,8 +15,6 @@ from feature_engine._docstrings.init_parameters.selection import (
     _confirm_variables_docstring,
 )
 from feature_engine._docstrings.methods import _fit_transform_docstring
-from feature_engine._docstrings.substitute import Substitution
-from feature_engine.dataframe_checks import check_X_y
 from feature_engine._docstrings.selection._docstring import (
     _cv_docstring,
     _estimator_docstring,
@@ -27,14 +28,13 @@ from feature_engine._docstrings.selection._docstring import (
     _variables_attribute_docstring,
     _variables_numerical_docstring,
 )
+from feature_engine._docstrings.substitute import Substitution
+from feature_engine.dataframe_checks import check_X_y
 from feature_engine.selection.base_selector import BaseSelector
 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 import (
-    find_numerical_variables,
     check_numerical_variables,
+    find_numerical_variables,
 )
 
 Variables = Union[None, int, str, List[Union[str, int]]]
diff --git a/feature_engine/selection/smart_correlation_selection.py b/feature_engine/selection/smart_correlation_selection.py
index f1b62ac..3a3bb68 100644
--- a/feature_engine/selection/smart_correlation_selection.py
+++ b/feature_engine/selection/smart_correlation_selection.py
@@ -3,6 +3,9 @@ from typing import List, Union
 import pandas as pd
 from sklearn.model_selection import cross_validate
 
+from feature_engine._check_init_parameters.check_variables import (
+    _check_variables_input_value,
+)
 from feature_engine._docstrings.fit_attributes import (
     _feature_names_in_docstring,
     _n_features_in_docstring,
@@ -11,12 +14,6 @@ from feature_engine._docstrings.init_parameters.selection import (
     _confirm_variables_docstring,
 )
 from feature_engine._docstrings.methods import _fit_transform_docstring
-from feature_engine._docstrings.substitute import Substitution
-from feature_engine.dataframe_checks import (
-    _check_contains_inf,
-    _check_contains_na,
-    check_X,
-)
 from feature_engine._docstrings.selection._docstring import (
     _cv_docstring,
     _estimator_docstring,
@@ -26,13 +23,16 @@ from feature_engine._docstrings.selection._docstring import (
     _variables_attribute_docstring,
     _variables_numerical_docstring,
 )
-from feature_engine.selection.base_selector import BaseSelector
-from feature_engine._check_init_parameters.check_variables import (
-    _check_variables_input_value,
+from feature_engine._docstrings.substitute import Substitution
+from feature_engine.dataframe_checks import (
+    _check_contains_inf,
+    _check_contains_na,
+    check_X,
 )
+from feature_engine.selection.base_selector import BaseSelector
 from feature_engine.variable_handling import (
-    find_numerical_variables,
     check_numerical_variables,
+    find_numerical_variables,
 )
 
 Variables = Union[None, int, str, List[Union[str, int]]]
diff --git a/feature_engine/selection/target_mean_selection.py b/feature_engine/selection/target_mean_selection.py
index c383512..d58c74a 100644
--- a/feature_engine/selection/target_mean_selection.py
+++ b/feature_engine/selection/target_mean_selection.py
@@ -4,6 +4,9 @@ import pandas as pd
 from sklearn.base import clone
 from sklearn.model_selection import cross_validate
 
+from feature_engine._check_init_parameters.check_variables import (
+    _check_variables_input_value,
+)
 from feature_engine._docstrings.fit_attributes import (
     _feature_names_in_docstring,
     _n_features_in_docstring,
@@ -12,10 +15,6 @@ from feature_engine._docstrings.init_parameters.selection import (
     _confirm_variables_docstring,
 )
 from feature_engine._docstrings.methods import _fit_transform_docstring
-from feature_engine._docstrings.substitute import Substitution
-from feature_engine._prediction.target_mean_classifier import TargetMeanClassifier
-from feature_engine._prediction.target_mean_regressor import TargetMeanRegressor
-from feature_engine.dataframe_checks import check_X_y
 from feature_engine._docstrings.selection._docstring import (
     _cv_docstring,
     _features_to_drop_docstring,
@@ -26,15 +25,16 @@ from feature_engine._docstrings.selection._docstring import (
     _transform_docstring,
     _variables_attribute_docstring,
 )
+from feature_engine._docstrings.substitute import Substitution
+from feature_engine._prediction.target_mean_classifier import TargetMeanClassifier
+from feature_engine._prediction.target_mean_regressor import TargetMeanRegressor
+from feature_engine.dataframe_checks import check_X_y
 from feature_engine.selection._selection_constants import (
     _CLASSIFICATION_METRICS,
     _REGRESSION_METRICS,
 )
 from feature_engine.selection.base_selector import BaseSelector
 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 find_all_variables
 
 Variables = Union[None, int, str, List[Union[str, int]]]
diff --git a/feature_engine/timeseries/forecasting/base_forecast_transformers.py b/feature_engine/timeseries/forecasting/base_forecast_transformers.py
index 2bb55fe..d6e9fa3 100644
--- a/feature_engine/timeseries/forecasting/base_forecast_transformers.py
+++ b/feature_engine/timeseries/forecasting/base_forecast_transformers.py
@@ -5,6 +5,9 @@ from sklearn.base import BaseEstimator, TransformerMixin
 from sklearn.utils.validation import check_is_fitted
 
 from feature_engine._base_transformers.mixins import GetFeatureNamesOutMixin
+from feature_engine._check_init_parameters.check_variables import (
+    _check_variables_input_value,
+)
 from feature_engine._docstrings.fit_attributes import (
     _feature_names_in_docstring,
     _n_features_in_docstring,
@@ -22,12 +25,9 @@ from feature_engine.dataframe_checks import (
     check_X,
 )
 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 import (
-    find_numerical_variables,
     check_numerical_variables,
+    find_numerical_variables,
 )
 
 
diff --git a/feature_engine/transformation/arcsin.py b/feature_engine/transformation/arcsin.py
index dded47b..95ace06 100644
--- a/feature_engine/transformation/arcsin.py
+++ b/feature_engine/transformation/arcsin.py
@@ -7,6 +7,9 @@ import numpy as np
 import pandas as pd
 
 from feature_engine._base_transformers.base_numerical import BaseNumericalTransformer
+from feature_engine._check_init_parameters.check_variables import (
+    _check_variables_input_value,
+)
 from feature_engine._docstrings.fit_attributes import (
     _feature_names_in_docstring,
     _n_features_in_docstring,
@@ -22,9 +25,6 @@ from feature_engine._docstrings.methods import (
 )
 from feature_engine._docstrings.substitute import Substitution
 from feature_engine.tags import _return_tags
-from feature_engine._check_init_parameters.check_variables import (
-    _check_variables_input_value,
-)
 
 
 @Substitution(
diff --git a/feature_engine/transformation/boxcox.py b/feature_engine/transformation/boxcox.py
index 52bbb3b..d503195 100644
--- a/feature_engine/transformation/boxcox.py
+++ b/feature_engine/transformation/boxcox.py
@@ -8,6 +8,9 @@ import scipy.stats as stats
 from scipy.special import inv_boxcox
 
 from feature_engine._base_transformers.base_numerical import BaseNumericalTransformer
+from feature_engine._check_init_parameters.check_variables import (
+    _check_variables_input_value,
+)
 from feature_engine._docstrings.fit_attributes import (
     _feature_names_in_docstring,
     _n_features_in_docstring,
@@ -22,9 +25,6 @@ from feature_engine._docstrings.methods import (
 )
 from feature_engine._docstrings.substitute import Substitution
 from feature_engine.tags import _return_tags
-from feature_engine._check_init_parameters.check_variables import (
-    _check_variables_input_value,
-)
 
 
 @Substitution(
diff --git a/feature_engine/transformation/log.py b/feature_engine/transformation/log.py
index 49601e4..b4b48f3 100644
--- a/feature_engine/transformation/log.py
+++ b/feature_engine/transformation/log.py
@@ -8,6 +8,9 @@ import pandas as pd
 
 from feature_engine._base_transformers.base_numerical import BaseNumericalTransformer
 from feature_engine._base_transformers.mixins import FitFromDictMixin
+from feature_engine._check_init_parameters.check_variables import (
+    _check_variables_input_value,
+)
 from feature_engine._docstrings.fit_attributes import (
     _feature_names_in_docstring,
     _n_features_in_docstring,
@@ -23,9 +26,6 @@ from feature_engine._docstrings.methods import (
 )
 from feature_engine._docstrings.substitute import Substitution
 from feature_engine.tags import _return_tags
-from feature_engine._check_init_parameters.check_variables import (
-    _check_variables_input_value,
-)
 
 
 @Substitution(
diff --git a/feature_engine/transformation/power.py b/feature_engine/transformation/power.py
index eb94361..0e53a4f 100644
--- a/feature_engine/transformation/power.py
+++ b/feature_engine/transformation/power.py
@@ -7,6 +7,9 @@ import numpy as np
 import pandas as pd
 
 from feature_engine._base_transformers.base_numerical import BaseNumericalTransformer
+from feature_engine._check_init_parameters.check_variables import (
+    _check_variables_input_value,
+)
 from feature_engine._docstrings.fit_attributes import (
     _feature_names_in_docstring,
     _n_features_in_docstring,
@@ -21,9 +24,6 @@ from feature_engine._docstrings.methods import (
     _inverse_transform_docstring,
 )
 from feature_engine._docstrings.substitute import Substitution
-from feature_engine._check_init_parameters.check_variables import (
-    _check_variables_input_value,
-)
 
 
 @Substitution(
diff --git a/feature_engine/transformation/reciprocal.py b/feature_engine/transformation/reciprocal.py
index 79efe3c..c4195be 100644
--- a/feature_engine/transformation/reciprocal.py
+++ b/feature_engine/transformation/reciprocal.py
@@ -7,6 +7,9 @@ import numpy as np
 import pandas as pd
 
 from feature_engine._base_transformers.base_numerical import BaseNumericalTransformer
+from feature_engine._check_init_parameters.check_variables import (
+    _check_variables_input_value,
+)
 from feature_engine._docstrings.fit_attributes import (
     _feature_names_in_docstring,
     _n_features_in_docstring,
@@ -22,9 +25,6 @@ from feature_engine._docstrings.methods import (
 )
 from feature_engine._docstrings.substitute import Substitution
 from feature_engine.tags import _return_tags
-from feature_engine._check_init_parameters.check_variables import (
-    _check_variables_input_value,
-)
 
 
 @Substitution(
diff --git a/feature_engine/transformation/yeojohnson.py b/feature_engine/transformation/yeojohnson.py
index 5760c04..5e33c05 100644
--- a/feature_engine/transformation/yeojohnson.py
+++ b/feature_engine/transformation/yeojohnson.py
@@ -8,6 +8,9 @@ import pandas as pd
 import scipy.stats as stats
 
 from feature_engine._base_transformers.base_numerical import BaseNumericalTransformer
+from feature_engine._check_init_parameters.check_variables import (
+    _check_variables_input_value,
+)
 from feature_engine._docstrings.fit_attributes import (
     _feature_names_in_docstring,
     _n_features_in_docstring,
@@ -22,9 +25,6 @@ from feature_engine._docstrings.methods import (
 )
 from feature_engine._docstrings.substitute import Substitution
 from feature_engine.tags import _return_tags
-from feature_engine._check_init_parameters.check_variables import (
-    _check_variables_input_value,
-)
 
 
 @Substitution(
diff --git a/feature_engine/variable_handling/__init__.py b/feature_engine/variable_handling/__init__.py
index 65b7a2d..d49303c 100644
--- a/feature_engine/variable_handling/__init__.py
+++ b/feature_engine/variable_handling/__init__.py
@@ -3,20 +3,28 @@ The module variable handling includes functions to select variables of a certain
 or check that a list of variables is in certain type.
 """
 
+from .check_variables import (
+    check_categorical_variables,
+    check_datetime_variables,
+    check_numerical_variables,
+)
+from .find_variables import (
+    find_categorical_variables,
+    find_datetime_variables,
+    find_numerical_variables,
+)
 from .variable_selection import (
     find_all_variables,
     find_categorical_and_numerical_variables,
-    find_or_check_datetime_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_datetime_variables",
     "check_numerical_variables",
     "check_categorical_variables",
+    "check_datetime_variables",
     "find_numerical_variables",
     "find_categorical_variables",
+    "find_datetime_variables",
 ]
diff --git a/feature_engine/variable_handling/check_variables.py b/feature_engine/variable_handling/check_variables.py
index bff9fe6..155a4a5 100644
--- a/feature_engine/variable_handling/check_variables.py
+++ b/feature_engine/variable_handling/check_variables.py
@@ -1,6 +1,11 @@
 from typing import List, Union
 
 import pandas as pd
+from pandas.api.types import is_numeric_dtype as is_numeric
+
+from feature_engine.variable_handling._variable_type_checks import (
+    _is_categorical_and_is_datetime,
+)
 
 Variables = Union[int, str, List[Union[str, int]]]
 
@@ -19,7 +24,7 @@ def check_numerical_variables(
         The dataset
 
     variables : List
-        List with the names of the variables to check.
+        The list with the names of the variables to check.
 
     Returns
     -------
@@ -66,7 +71,7 @@ def check_categorical_variables(
         The dataset
 
     variables : list
-        List with the names of the variables to check.
+        The list with the names of the variables to check.
 
     Returns
     -------
@@ -97,3 +102,55 @@ def check_categorical_variables(
         )
 
     return variables
+
+
+def check_datetime_variables(
+    X: pd.DataFrame, variables: Variables,
+) -> List[Union[str, int]]:
+    """
+    Checks that the variables in the list are or can be parsed as datetime.
+
+    More details in the :ref:`User Guide <check_datetime_vars>`.
+
+    Parameters
+    ----------
+    X : pandas dataframe of shape = [n_samples, n_features]
+        The dataset
+
+    variables : list
+        The list with the names of the variables to check.
+
+    Returns
+    -------
+    variables: List
+        The names of the datetime variables.
+
+    Examples
+    --------
+    >>> import pandas as pd
+    >>> from feature_engine.variable_handling import check_datetime_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_date = check_datetime_variables(X, "var_date")
+    >>> var_date
+    ['var_date']
+    """
+
+    if isinstance(variables, (str, int)):
+        variables = [variables]
+
+    # find non datetime variables, if any:
+    non_datetime_vars = []
+    for column in X[variables].select_dtypes(exclude="datetime"):
+        if is_numeric(X[column]) or not _is_categorical_and_is_datetime(X[column]):
+            non_datetime_vars.append(column)
+
+    if len(non_datetime_vars) > 0:
+        raise TypeError(
+            "Some of the variables are not or cannot be parsed as datetime."
+        )
+
+    return variables
diff --git a/feature_engine/variable_handling/find_variables.py b/feature_engine/variable_handling/find_variables.py
index 0b0c803..c732a38 100644
--- a/feature_engine/variable_handling/find_variables.py
+++ b/feature_engine/variable_handling/find_variables.py
@@ -1,8 +1,10 @@
 from typing import List, Union
 
 import pandas as pd
+from pandas.api.types import is_datetime64_any_dtype as is_datetime
 
 from feature_engine.variable_handling._variable_type_checks import (
+    _is_categorical_and_is_datetime,
     _is_categorical_and_is_not_datetime,
 )
 
@@ -87,3 +89,49 @@ def find_categorical_variables(X: pd.DataFrame) -> List[Union[str, int]]:
             "variable format with pandas dtypes."
         )
     return variables
+
+
+def find_datetime_variables(X: pd.DataFrame) -> List[Union[str, int]]:
+    """
+    Returns a list with the names of the variables that are or can be parsed as
+    datetime.
+
+    Note that this function will select variables cast as object if they can be cast as
+    datetime as well.
+
+    More details in the :ref:`User Guide <find_datetime_vars>`.
+
+    Parameters
+    ----------
+    X : pandas dataframe of shape = [n_samples, n_features]
+        The dataset.
+
+    Returns
+    -------
+    variables: List
+        The names of the datetime variables.
+
+    Examples
+    --------
+    >>> import pandas as pd
+    >>> from feature_engine.variable_handling import find_datetime_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_date = find_datetime_variables(X)
+    >>> var_date
+    ['var_date']
+    """
+
+    variables = [
+        column
+        for column in X.select_dtypes(exclude="number").columns
+        if is_datetime(X[column]) or _is_categorical_and_is_datetime(X[column])
+    ]
+
+    if len(variables) == 0:
+        raise ValueError("No datetime variables found in this dataframe.")
+
+    return variables
diff --git a/feature_engine/variable_handling/variable_selection.py b/feature_engine/variable_handling/variable_selection.py
index 61de359..85cdfbe 100644
--- a/feature_engine/variable_handling/variable_selection.py
+++ b/feature_engine/variable_handling/variable_selection.py
@@ -3,100 +3,16 @@
 from typing import List, Tuple, Union
 
 import pandas as pd
-from pandas.api.types import is_datetime64_any_dtype as is_datetime
 from pandas.api.types import is_numeric_dtype as is_numeric
 from pandas.api.types import is_object_dtype as is_object
 
 from feature_engine.variable_handling._variable_type_checks import (
-    _is_categorical_and_is_datetime,
     _is_categorical_and_is_not_datetime,
 )
 
 Variables = Union[None, int, str, List[Union[str, int]]]
 
 
-def find_or_check_datetime_variables(
-    X: pd.DataFrame, variables: Variables = None
-) -> List[Union[str, int]]:
-    """
-    Returns the names of all the variables that are or can be parsed as datetime.
-    Alternatively, it checks that the variables entered by the user can be parsed as
-    datetime.
-
-    Note that this function will select variables cast as object if they can be cast as
-    datetime as well.
-
-    More details in the :ref:`User Guide <find_datetime_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 variables in X that can be
-        parsed as datetime. These include those cast as datetime, and also object and
-        categorical if they can be transformed to datetime variables. Alternatively, it
-        checks that the variables in the list are or can be parsed to datetime.
-
-    Returns
-    -------
-    variables: List
-        The names of the datetime variables.
-
-    Examples
-    --------
-    >>> import pandas as pd
-    >>> from feature_engine.variable_handling import find_or_check_datetime_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_date = find_or_check_datetime_variables(X)
-    >>> var_date
-    ['var_date']
-    """
-
-    if variables is None:
-        variables = [
-            column
-            for column in X.select_dtypes(exclude="number").columns
-            if is_datetime(X[column]) or _is_categorical_and_is_datetime(X[column])
-        ]
-
-        if len(variables) == 0:
-            raise ValueError("No datetime variables found in this dataframe.")
-
-    elif isinstance(variables, (str, int)):
-
-        if is_datetime(X[variables]) or (
-            not is_numeric(X[variables])
-            and _is_categorical_and_is_datetime(X[variables])
-        ):
-            variables = [variables]
-        else:
-            raise TypeError("The variable entered is not datetime.")
-
-    else:
-        if len(variables) == 0:
-            raise ValueError("The indicated list of variables is empty.")
-
-        # check that the variables entered by the user are datetime
-        else:
-            vars_non_dt = [
-                column
-                for column in X[variables].select_dtypes(exclude="datetime")
-                if is_numeric(X[column])
-                or not _is_categorical_and_is_datetime(X[column])
-            ]
-
-            if len(vars_non_dt) > 0:
-                raise TypeError("Some of the variables are not datetime.")
-
-    return variables
-
-
 def find_all_variables(
     X: pd.DataFrame,
     variables: Variables = None,
diff --git a/feature_engine/wrappers/wrappers.py b/feature_engine/wrappers/wrappers.py
index 61764d8..1fba703 100644
--- a/feature_engine/wrappers/wrappers.py
+++ b/feature_engine/wrappers/wrappers.py
@@ -4,18 +4,16 @@ import pandas as pd
 from sklearn.base import BaseEstimator, TransformerMixin, clone
 from sklearn.utils.validation import check_is_fitted
 
-from feature_engine.dataframe_checks import _check_X_matches_training_df, check_X
-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 (
-    find_all_variables,
-)
+from feature_engine.dataframe_checks import _check_X_matches_training_df, check_X
+from feature_engine.tags import _return_tags
 from feature_engine.variable_handling import (
-    find_numerical_variables,
     check_numerical_variables,
+    find_numerical_variables,
 )
+from feature_engine.variable_handling.variable_selection import find_all_variables
 
 _SELECTORS = [
     "GenericUnivariateSelect",


Test patch:
diff --git a/tests/conftest.py b/tests/conftest.py
index e6e664c..6b56dfe 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -18,22 +18,6 @@ def df_vartypes():
     return df
 
 
-@pytest.fixture(scope="module")
-def df_datetime():
-    data = {
-        "Name": ["tom", "nick", "krish", "jack"],
-        "Age": [20, 21, 19, 18],
-        "datetime_range": pd.date_range("2020-02-24", periods=4, freq="D"),
-        "date_obj1": ["01-Jan-2010", "24-Feb-1945", "14-Jun-2100", "17-May-1999"],
-        "date_obj2": ["10/11/12", "12/31/09", "06/30/95", "03/17/04"],
-        "time_obj": ["21:45:23", "09:15:33", "12:34:59", "03:27:02"],
-    }
-
-    df = pd.DataFrame(data)
-
-    return df
-
-
 @pytest.fixture(scope="module")
 def df_numeric_columns():
     data = {
diff --git a/tests/test_datetime/conftest.py b/tests/test_datetime/conftest.py
index 8a49b32..7413361 100644
--- a/tests/test_datetime/conftest.py
+++ b/tests/test_datetime/conftest.py
@@ -2,7 +2,23 @@ import pandas as pd
 import pytest
 
 
-@pytest.fixture(scope="module")
+@pytest.fixture
+def df_datetime():
+    data = {
+        "Name": ["tom", "nick", "krish", "jack"],
+        "Age": [20, 21, 19, 18],
+        "datetime_range": pd.date_range("2020-02-24", periods=4, freq="D"),
+        "date_obj1": ["01-Jan-2010", "24-Feb-1945", "14-Jun-2100", "17-May-1999"],
+        "date_obj2": ["10/11/12", "12/31/09", "06/30/95", "03/17/04"],
+        "time_obj": ["21:45:23", "09:15:33", "12:34:59", "03:27:02"],
+    }
+
+    df = pd.DataFrame(data)
+
+    return df
+
+
+@pytest.fixture
 def df_datetime_transformed(df_datetime):
     today = pd.Timestamp.today()
     data = {
diff --git a/tests/test_datetime/test_datetime_subtraction.py b/tests/test_datetime/test_datetime_subtraction.py
index d256a32..25a62ca 100644
--- a/tests/test_datetime/test_datetime_subtraction.py
+++ b/tests/test_datetime/test_datetime_subtraction.py
@@ -28,7 +28,7 @@ def test_init_parameters_variables_and_reference_raise_error(_input_vars):
     with pytest.raises(ValueError):
         assert DatetimeSubtraction(variables=_input_vars, reference=["var1"])
     with pytest.raises(ValueError):
-        assert DatetimeSubtraction(reference=_input_vars, variables=["var1"])
+        assert DatetimeSubtraction(variables=["var1"], reference=_input_vars)
 
 
 @pytest.mark.parametrize("_input_vars", ["var1", ["var1"], ["var1", "var2"]])
@@ -38,12 +38,10 @@ def test_init_parameters_variables_and_reference_correct_assignment(_input_vars)
     assert transformer.reference == _input_vars
 
 
-@pytest.mark.parametrize("_input_vars", ["var1", ["var1"], ["var1", "var2"]])
-def test_init_parameters_variables_and_reference_are_mandatory(_input_vars):
-    with pytest.raises(TypeError):
-        DatetimeSubtraction(reference=["var1"])
-    with pytest.raises(TypeError):
-        DatetimeSubtraction(variables=["var1"])
+def test_init_parameters_variables_and_reference_take_none():
+    tr = DatetimeSubtraction()
+    assert tr.variables is None
+    assert tr.reference is None
 
 
 @pytest.mark.parametrize(
@@ -137,19 +135,34 @@ def test_missing_values_raises_error_when_not_valid(param):
 
 
 # ==== fit functionality
-def test_raises_error_when_variables_not_datetime(df_datetime):
+@pytest.mark.parametrize("input_vars", [["Age", "date_obj2"], "Age"])
+def test_raises_error_when_variables_not_datetime(df_datetime, input_vars):
+    tr = DatetimeSubtraction(variables=input_vars, reference="date_obj1")
     with pytest.raises(TypeError):
-        DatetimeSubtraction(variables="Age", reference="date_obj1").fit(df_datetime)
+        tr.fit(df_datetime)
+
+
+@pytest.mark.parametrize("input_vars", [["Age", "date_obj2"], "Age"])
+def test_raises_error_when_reference_not_datetime(df_datetime, input_vars):
+    tr = DatetimeSubtraction(variables=["date_obj1"], reference=input_vars)
     with pytest.raises(TypeError):
-        DatetimeSubtraction(variables=["date_obj1"], reference=["Age"]).fit(df_datetime)
+        tr.fit(df_datetime)
 
 
-def test_sets_variables_if_datetime(df_datetime):
-    tr = DatetimeSubtraction(variables="date_obj1", reference="date_obj1").fit(
-        df_datetime
-    )
-    assert tr.variables_ == ["date_obj1"]
-    assert tr.reference_ == ["date_obj1"]
+@pytest.mark.parametrize("input_vars", [["time_obj", "date_obj2"], "date_obj2", None])
+def test_sets_variables_if_datetime(df_datetime, input_vars):
+    tr = DatetimeSubtraction(variables=input_vars, reference=input_vars)
+    tr.fit(df_datetime)
+    if input_vars is None:
+        dt_vars = ["datetime_range", "date_obj1", "date_obj2", "time_obj"]
+        assert tr.variables_ == dt_vars
+        assert tr.reference_ == dt_vars
+    elif input_vars == "date_obj2":
+        assert tr.variables_ == ["date_obj2"]
+        assert tr.reference_ == ["date_obj2"]
+    else:
+        assert tr.variables_ == ["time_obj", "date_obj2"]
+        assert tr.reference_ == ["time_obj", "date_obj2"]
 
 
 @pytest.mark.parametrize("new", [["new1", "new2"], ["new1", "new2", "new3"]])
@@ -161,55 +174,62 @@ def test_new_variables_raise_error_if_not_adequate_number(df_datetime, new):
         tr.fit(df_datetime)
 
 
-def test_raises_error_when_nan_in_fit():
+@pytest.fixture
+def df_nan():
     df = pd.DataFrame(
         {
             "dates_na": ["Feb-2010", np.nan, "Jun-1922", np.nan],
             "dates_full": ["Feb-2010", "Mar-2010", "Jun-1922", "Feb-2011"],
         }
     )
+    return df
+
 
+@pytest.mark.parametrize("input_vars_1", ["dates_full", None])
+@pytest.mark.parametrize("input_vars_2", ["dates_na", ["dates_full", "dates_na"], None])
+def test_raises_error_when_nan_in_variables_in_fit(df_nan, input_vars_1, input_vars_2):
     tr = DatetimeSubtraction(
-        variables="dates_na", reference="dates_full", missing_values="raise"
+        variables=input_vars_2, reference=input_vars_1, missing_values="raise"
     )
     with pytest.raises(ValueError):
-        tr.fit(df)
+        tr.fit(df_nan)
 
+
+@pytest.mark.parametrize("input_vars_1", ["dates_full", None])
+@pytest.mark.parametrize("input_vars_2", ["dates_na", ["dates_full", "dates_na"], None])
+def test_raises_error_when_nan_in_reference_in_fit(df_nan, input_vars_1, input_vars_2):
     tr = DatetimeSubtraction(
-        variables="dates_full", reference="dates_na", missing_values="raise"
+        variables=input_vars_1, reference=input_vars_2, missing_values="raise"
     )
     with pytest.raises(ValueError):
-        tr.fit(df)
+        tr.fit(df_nan)
 
 
 # transform tests
-def test_raises_error_when_nan_in_transform():
-    df_fit = pd.DataFrame(
-        {
-            "dates_na": ["Feb-2010", "Mar-2010", "Jun-1922", "Feb-2011"],
-            "dates_full": ["Feb-2010", "Mar-2010", "Jun-1922", "Feb-2011"],
-        }
-    )
-    df_transform = pd.DataFrame(
-        {
-            "dates_na": ["Feb-2010", np.nan, "Jun-1922", np.nan],
-            "dates_full": ["Feb-2010", "Mar-2010", "Jun-1922", "Feb-2011"],
-        }
-    )
-
+@pytest.mark.parametrize("input_vars_1", ["dates_full", None])
+@pytest.mark.parametrize("input_vars_2", ["dates_na", ["dates_full", "dates_na"], None])
+def test_raises_error_when_nan_in_variables_in_transform(
+    df_nan, input_vars_1, input_vars_2
+):
     tr = DatetimeSubtraction(
-        variables="dates_na", reference="dates_full", missing_values="raise"
+        variables=input_vars_2, reference=input_vars_1, missing_values="raise"
     )
-    tr.fit(df_fit)
+    tr.fit(df_nan.fillna("Mar-2010"))
     with pytest.raises(ValueError):
-        tr.fit(df_transform)
+        tr.transform(df_nan)
+
 
+@pytest.mark.parametrize("input_vars_1", ["dates_full", None])
+@pytest.mark.parametrize("input_vars_2", ["dates_na", ["dates_full", "dates_na"], None])
+def test_raises_error_when_nan_in_reference_in_transform(
+    df_nan, input_vars_1, input_vars_2
+):
     tr = DatetimeSubtraction(
-        variables="dates_full", reference="dates_na", missing_values="raise"
+        variables=input_vars_1, reference=input_vars_2, missing_values="raise"
     )
-    tr.fit(df_fit)
+    tr.fit(df_nan.fillna("Mar-2010"))
     with pytest.raises(ValueError):
-        tr.fit(df_transform)
+        tr.transform(df_nan)
 
 
 @pytest.mark.parametrize(
diff --git a/tests/test_sklearn_compatible/test_set_output.py b/tests/test_sklearn_compatible/test_set_output.py
index 272c917..807dea3 100644
--- a/tests/test_sklearn_compatible/test_set_output.py
+++ b/tests/test_sklearn_compatible/test_set_output.py
@@ -1,6 +1,5 @@
 import numpy as np
 import pandas as pd
-
 from sklearn.datasets import load_iris
 from sklearn.linear_model import LogisticRegression
 from sklearn.pipeline import make_pipeline
diff --git a/tests/test_variable_handling/conftest.py b/tests/test_variable_handling/conftest.py
new file mode 100644
index 0000000..bee9089
--- /dev/null
+++ b/tests/test_variable_handling/conftest.py
@@ -0,0 +1,39 @@
+import pandas as pd
+import pytest
+
+
+@pytest.fixture
+def df():
+    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],
+            "date_range": pd.date_range("2020-02-24", periods=4, freq="T"),
+            "date_obj0": ["2020-02-24", "2020-02-25", "2020-02-26", "2020-02-27"],
+        }
+    )
+    df["Name"] = df["Name"].astype("category")
+    return df
+
+
+@pytest.fixture
+def df_int(df):
+    df = df.copy()
+    df.columns = [1, 2, 3, 4, 5, 6]
+    return df
+
+
+@pytest.fixture
+def df_datetime(df):
+    df = df.copy()
+
+    df["date_obj1"] = ["01-Jan-2010", "24-Feb-1945", "14-Jun-2100", "17-May-1999"]
+    df["date_obj2"] = ["10/11/12", "12/31/09", "06/30/95", "03/17/04"]
+    df["time_obj"] = ["21:45:23", "09:15:33", "12:34:59", "03:27:02"]
+
+    df["time_objTZ"] = df["time_obj"].add(["+5", "+11", "-3", "-8"])
+    df["date_obj1"] = df["date_obj1"].astype("category")
+    df["Age"] = df["Age"].astype("O")
+    return df
diff --git a/tests/test_variable_handling/test_check_variables.py b/tests/test_variable_handling/test_check_variables.py
index 387c8d1..ad892c3 100644
--- a/tests/test_variable_handling/test_check_variables.py
+++ b/tests/test_variable_handling/test_check_variables.py
@@ -1,36 +1,13 @@
-import pandas as pd
 import pytest
 
 from feature_engine.variable_handling import (
-    check_numerical_variables,
     check_categorical_variables,
+    check_datetime_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"),
-        "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():
+def test_check_numerical_variables_returns_numerical_variables(df, df_int):
     assert check_numerical_variables(df, ["Age", "Marks"]) == ["Age", "Marks"]
     assert check_numerical_variables(df, ["Age"]) == ["Age"]
     assert check_numerical_variables(df, "Age") == ["Age"]
@@ -39,7 +16,7 @@ def test_check_numerical_variables_returns_numerical_variables():
     assert check_numerical_variables(df_int, 4) == [4]
 
 
-def test_check_numerical_variables_raises_errors_when_not_numerical():
+def test_check_numerical_variables_raises_errors_when_not_numerical(df, df_int):
     msg = (
         "Some of the variables are not numerical. Please cast them as "
         "numerical before using this transformer."
@@ -69,16 +46,19 @@ def test_check_numerical_variables_raises_errors_when_not_numerical():
     assert str(record.value) == msg
 
 
-def test_check_categorical_variables_returns_categorical_variables():
-    assert check_categorical_variables(df, ["Name", "date"]) == ["Name", "date"]
+def test_check_categorical_variables_returns_categorical_variables(df, df_int):
+    assert check_categorical_variables(df, ["Name", "date_obj0"]) == [
+        "Name",
+        "date_obj0",
+    ]
     assert check_categorical_variables(df, ["Name"]) == ["Name"]
-    assert check_categorical_variables(df, "date") == ["date"]
+    assert check_categorical_variables(df, "date_obj0") == ["date_obj0"]
     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():
+def test_check_categorical_variables_raises_errors_when_not_categorical(df, df_int):
     msg = (
         "Some of the variables are not categorical. Please cast them as "
         "object or categorical before using this transformer."
@@ -106,3 +86,39 @@ def test_check_categorical_variables_raises_errors_when_not_categorical():
     with pytest.raises(TypeError) as record:
         assert check_categorical_variables(df_int, [2, 3])
     assert str(record.value) == msg
+
+
+def test_check_datetime_variables_returns_datetime_variables(df_datetime):
+    var_dt = ["date_range"]
+    var_dt_str = "date_range"
+    vars_convertible_to_dt = ["date_range", "date_obj1", "date_obj2", "time_obj"]
+    var_convertible_to_dt = "date_obj1"
+    tz_time = "time_objTZ"
+
+    # when variables are specified
+    assert check_datetime_variables(df_datetime, var_dt_str) == [var_dt_str]
+    assert check_datetime_variables(df_datetime, var_dt) == var_dt
+    assert check_datetime_variables(df_datetime, var_convertible_to_dt) == [
+        var_convertible_to_dt
+    ]
+    assert (
+        check_datetime_variables(df_datetime, vars_convertible_to_dt)
+        == vars_convertible_to_dt
+    )
+    assert check_datetime_variables(df_datetime, tz_time) == [tz_time]
+
+
+def test_check_datetime_variables_raises_errors_when_not_datetime(df_datetime):
+    msg = "Some of the variables are not or cannot be parsed as datetime."
+
+    with pytest.raises(TypeError) as record:
+        assert check_datetime_variables(df_datetime, variables="Age")
+    assert str(record.value) == msg
+
+    with pytest.raises(TypeError) as record:
+        assert check_datetime_variables(df_datetime, variables=["Age", "Name"])
+    assert str(record.value) == msg
+
+    with pytest.raises(TypeError):
+        assert check_datetime_variables(df_datetime, variables=["date_range", "Age"])
+    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
index aafb8f2..6fb81dc 100644
--- a/tests/test_variable_handling/test_find_variables.py
+++ b/tests/test_variable_handling/test_find_variables.py
@@ -1,41 +1,18 @@
-import pandas as pd
 import pytest
 
 from feature_engine.variable_handling import (
-    find_numerical_variables,
     find_categorical_variables,
+    find_datetime_variables,
+    find_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"),
-        "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():
+def test_numerical_variables_finds_numerical_variables(df, df_int):
     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():
+def test_numerical_variables_raises_error_when_no_numerical_variables(df, df_int):
     msg = (
         "No numerical variables found in this dataframe. Please check "
         "variable format with pandas dtypes."
@@ -49,12 +26,12 @@ def test_numerical_variables_raises_error_when_no_numerical_variables():
     assert str(record.value) == msg
 
 
-def test_categorical_variables_finds_categorical_variables():
+def test_categorical_variables_finds_categorical_variables(df, df_int):
     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():
+def test_categorical_variables_raises_error_when_no_categorical_variables(df, df_int):
     msg = (
         "No categorical variables found in this dataframe. Please check "
         "variable format with pandas dtypes."
@@ -66,3 +43,31 @@ def test_categorical_variables_raises_error_when_no_categorical_variables():
     with pytest.raises(TypeError) as record:
         assert find_categorical_variables(df_int.drop([1, 2], axis=1))
     assert str(record.value) == msg
+
+
+def test_datetime_variables_finds_datetime_variables(df_datetime):
+    vars_dt = [
+        "date_range",
+        "date_obj0",
+        "date_obj1",
+        "date_obj2",
+        "time_obj",
+        "time_objTZ",
+    ]
+
+    assert find_datetime_variables(df_datetime) == vars_dt
+
+    assert find_datetime_variables(
+        df_datetime[vars_dt].reindex(columns=["date_obj1", "date_range", "date_obj2"]),
+    ) == ["date_obj1", "date_range", "date_obj2"]
+
+
+def test_datetime_variables_raises_error_when_no_datetime_variables(df_datetime):
+
+    msg = "No datetime variables found in this dataframe."
+
+    vars_nondt = ["Marks", "Age", "Name"]
+
+    with pytest.raises(ValueError) as record:
+        assert find_datetime_variables(df_datetime.loc[:, vars_nondt])
+    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 239194b..aa009c7 100644
--- a/tests/test_variable_handling/test_variable_selection.py
+++ b/tests/test_variable_handling/test_variable_selection.py
@@ -5,103 +5,9 @@ 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_datetime_variables,
 )
 
 
-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_datetime_variables(df_datetime):
-    var_dt = ["datetime_range"]
-    var_dt_str = "datetime_range"
-    vars_nondt = ["Age", "Name"]
-    vars_convertible_to_dt = ["datetime_range", "date_obj1", "date_obj2", "time_obj"]
-    var_convertible_to_dt = "date_obj1"
-    vars_mix = ["datetime_range", "Age"]
-    tz_time = pd.DataFrame(
-        {"time_objTZ": df_datetime["time_obj"].add(["+5", "+11", "-3", "-8"])}
-    )
-
-    # error when df has no datetime variables
-    with pytest.raises(ValueError):
-        assert find_or_check_datetime_variables(
-            df_datetime.loc[:, vars_nondt], variables=None
-        )
-
-    # errors when vars entered by user are not datetime
-    with pytest.raises(TypeError):
-        assert find_or_check_datetime_variables(df_datetime, variables="Age")
-    with pytest.raises(TypeError):
-        assert find_or_check_datetime_variables(df_datetime, variables=vars_nondt)
-    with pytest.raises(TypeError):
-        assert find_or_check_datetime_variables(df_datetime, variables=vars_mix)
-
-    # error when user enters empty list
-    with pytest.raises(ValueError):
-        assert find_or_check_datetime_variables(df_datetime, variables=[])
-
-    # when variables=None
-    assert (
-        find_or_check_datetime_variables(df_datetime, variables=None)
-        == vars_convertible_to_dt
-    )
-    assert find_or_check_datetime_variables(
-        df_datetime[vars_convertible_to_dt].reindex(
-            columns=["date_obj1", "datetime_range", "date_obj2"]
-        ),
-        variables=None,
-    ) == ["date_obj1", "datetime_range", "date_obj2"]
-
-    # when variables are specified
-    assert find_or_check_datetime_variables(df_datetime, var_dt_str) == [var_dt_str]
-    assert find_or_check_datetime_variables(df_datetime, var_dt) == var_dt
-    assert find_or_check_datetime_variables(
-        df_datetime, variables=var_convertible_to_dt
-    ) == [var_convertible_to_dt]
-    assert (
-        find_or_check_datetime_variables(df_datetime, variables=vars_convertible_to_dt)
-        == vars_convertible_to_dt
-    )
-    assert find_or_check_datetime_variables(
-        df_datetime.join(tz_time),
-        variables=None,
-    ) == vars_convertible_to_dt + ["time_objTZ"]
-
-    # datetime var cast as categorical
-    df_datetime["date_obj1"] = df_datetime["date_obj1"].astype("category")
-    assert find_or_check_datetime_variables(df_datetime, variables="date_obj1") == [
-        "date_obj1"
-    ]
-    assert (
-        find_or_check_datetime_variables(df_datetime, variables=vars_convertible_to_dt)
-        == vars_convertible_to_dt
-    )
-
-
-@pytest.mark.parametrize("_num_var, _cat_type", [("Age", "category"), ("Age", "O")])
-def test_find_or_check_datetime_variables_when_numeric_is_cast_as_category_or_object(
-    df_datetime, _num_var, _cat_type
-):
-    df_datetime = _cast_var_as_type(df_datetime, _num_var, _cat_type)
-    with pytest.raises(TypeError):
-        assert find_or_check_datetime_variables(df_datetime, variables=_num_var)
-    with pytest.raises(TypeError):
-        assert find_or_check_datetime_variables(df_datetime, variables=[_num_var])
-    with pytest.raises(ValueError) as errinfo:
-        assert find_or_check_datetime_variables(df_datetime[[_num_var]], variables=None)
-    assert str(errinfo.value) == "No datetime variables found in this dataframe."
-    assert find_or_check_datetime_variables(df_datetime, variables=None) == [
-        "datetime_range",
-        "date_obj1",
-        "date_obj2",
-        "time_obj",
-    ]
-
-
 def test_find_all_variables(df_vartypes):
     all_vars = ["Name", "City", "Age", "Marks", "dob"]
     all_vars_no_dt = ["Name", "City", "Age", "Marks"]