Repository: feature-engine/feature_engine
Pull request #408 (2022-04-06 17:15:03)

extends is_dataframe functionality and renames to check_X
FYI @noahjgreen295 @KishManani 

I am restructuring and renaming `is_dataframe` at the back of the bug reported by @noahjgreen295 which made me find more bugs


Patch:
diff --git a/feature_engine/_prediction/base_predictor.py b/feature_engine/_prediction/base_predictor.py
index 35a9e52..243e164 100644
--- a/feature_engine/_prediction/base_predictor.py
+++ b/feature_engine/_prediction/base_predictor.py
@@ -9,15 +9,15 @@ from sklearn.utils.validation import check_is_fitted
 from feature_engine.dataframe_checks import (
     _check_contains_inf,
     _check_contains_na,
-    _check_input_matches_training_df,
-    _is_dataframe,
+    _check_X_matches_training_df,
+    check_X,
 )
 from feature_engine.discretisation import (
     EqualFrequencyDiscretiser,
     EqualWidthDiscretiser,
 )
 from feature_engine.encoding import MeanEncoder
-from feature_engine.validation import _return_tags
+from feature_engine.tags import _return_tags
 from feature_engine.variable_manipulation import (
     _check_input_parameter_variables,
     _find_categorical_and_numerical_variables,
@@ -112,7 +112,7 @@ class BaseTargetMeanEstimator(BaseEstimator):
             The target variable.
         """
         # check if 'X' is a dataframe
-        X = _is_dataframe(X)
+        X = check_X(X)
 
         # Check X and y for consistent length
         if len(X) != len(y):
@@ -258,10 +258,10 @@ class BaseTargetMeanEstimator(BaseEstimator):
         check_is_fitted(self)
 
         # check that input is a dataframe
-        X = _is_dataframe(X)
+        X = check_X(X)
 
         # Check input data contains same number of columns as df used to fit
-        _check_input_matches_training_df(X, self.n_features_in_)
+        _check_X_matches_training_df(X, self.n_features_in_)
 
         # check for missing values
         _check_contains_na(X, self.variables_numerical_)
diff --git a/feature_engine/base_transformers.py b/feature_engine/base_transformers.py
index d2240d5..5b553da 100644
--- a/feature_engine/base_transformers.py
+++ b/feature_engine/base_transformers.py
@@ -11,10 +11,10 @@ from sklearn.utils.validation import check_is_fitted
 from feature_engine.dataframe_checks import (
     _check_contains_inf,
     _check_contains_na,
-    _check_input_matches_training_df,
-    _is_dataframe,
+    _check_X_matches_training_df,
+    check_X,
 )
-from feature_engine.validation import _return_tags
+from feature_engine.tags import _return_tags
 from feature_engine.variable_manipulation import _find_or_check_numerical_variables
 
 
@@ -50,7 +50,7 @@ class BaseNumericalTransformer(BaseEstimator, TransformerMixin):
             The same dataframe entered as parameter
         """
         # check input dataframe
-        X = _is_dataframe(X)
+        X = check_X(X)
 
         # find or check for numerical variables
         variables = [x for x in user_dict_.keys()]
@@ -96,7 +96,7 @@ class BaseNumericalTransformer(BaseEstimator, TransformerMixin):
         """
 
         # check input dataframe
-        X = _is_dataframe(X)
+        X = check_X(X)
 
         # find or check for numerical variables
         self.variables_ = _find_or_check_numerical_variables(X, self.variables)
@@ -140,10 +140,10 @@ class BaseNumericalTransformer(BaseEstimator, TransformerMixin):
         check_is_fitted(self)
 
         # check that input is a dataframe
-        X = _is_dataframe(X)
+        X = check_X(X)
 
         # Check if input data contains same number of columns as dataframe used to fit.
-        _check_input_matches_training_df(X, self.n_features_in_)
+        _check_X_matches_training_df(X, self.n_features_in_)
 
         # check if dataset contains na or inf
         _check_contains_na(X, self.variables_)
diff --git a/feature_engine/creation/base_creation.py b/feature_engine/creation/base_creation.py
index 9ed2a84..6391637 100644
--- a/feature_engine/creation/base_creation.py
+++ b/feature_engine/creation/base_creation.py
@@ -7,10 +7,10 @@ from sklearn.utils.validation import check_is_fitted
 from feature_engine.dataframe_checks import (
     _check_contains_inf,
     _check_contains_na,
-    _check_input_matches_training_df,
-    _is_dataframe,
+    _check_X_matches_training_df,
+    check_X,
 )
-from feature_engine.validation import _return_tags
+from feature_engine.tags import _return_tags
 from feature_engine.variable_manipulation import _find_or_check_numerical_variables
 
 
@@ -56,7 +56,7 @@ class BaseCreation(BaseEstimator, TransformerMixin):
         """
 
         # check input dataframe
-        X = _is_dataframe(X)
+        X = check_X(X)
 
         # check variables are numerical
         self.variables: List[Union[str, int]] = _find_or_check_numerical_variables(
@@ -95,10 +95,10 @@ class BaseCreation(BaseEstimator, TransformerMixin):
         check_is_fitted(self)
 
         # check that input is a dataframe
-        X = _is_dataframe(X)
+        X = check_X(X)
 
         # Check if input data contains same number of columns as dataframe used to fit.
-        _check_input_matches_training_df(X, self.n_features_in_)
+        _check_X_matches_training_df(X, self.n_features_in_)
 
         # check if dataset contains na
         if self.missing_values == "raise":
diff --git a/feature_engine/creation/combine_with_reference_feature.py b/feature_engine/creation/combine_with_reference_feature.py
index ac4bed2..7f720e3 100644
--- a/feature_engine/creation/combine_with_reference_feature.py
+++ b/feature_engine/creation/combine_with_reference_feature.py
@@ -8,8 +8,8 @@ from sklearn.utils.validation import check_is_fitted
 from feature_engine.dataframe_checks import (
     _check_contains_inf,
     _check_contains_na,
-    _check_input_matches_training_df,
-    _is_dataframe,
+    _check_X_matches_training_df,
+    check_X,
 )
 from feature_engine.docstrings import (
     Substitution,
@@ -20,7 +20,7 @@ from feature_engine.docstrings import (
     _missing_values_docstring,
     _n_features_in_docstring,
 )
-from feature_engine.validation import _return_tags
+from feature_engine.tags import _return_tags
 from feature_engine.variable_manipulation import _find_or_check_numerical_variables
 
 
@@ -210,7 +210,7 @@ class CombineWithReferenceFeature(BaseEstimator, TransformerMixin):
         """
 
         # check input dataframe
-        X = _is_dataframe(X)
+        X = check_X(X)
 
         # check variables to combine are numerical
         self.variables_to_combine = _find_or_check_numerical_variables(
@@ -265,10 +265,10 @@ class CombineWithReferenceFeature(BaseEstimator, TransformerMixin):
         check_is_fitted(self)
 
         # check that input is a dataframe
-        X = _is_dataframe(X)
+        X = check_X(X)
 
         # Check if input data contains same number of columns as dataframe used to fit.
-        _check_input_matches_training_df(X, self.n_features_in_)
+        _check_X_matches_training_df(X, self.n_features_in_)
 
         # check if dataset contains na
         if self.missing_values == "raise":
diff --git a/feature_engine/creation/mathematical_combination.py b/feature_engine/creation/mathematical_combination.py
index dbe7f81..4a54538 100644
--- a/feature_engine/creation/mathematical_combination.py
+++ b/feature_engine/creation/mathematical_combination.py
@@ -8,8 +8,8 @@ from sklearn.utils.validation import check_is_fitted
 from feature_engine.dataframe_checks import (
     _check_contains_inf,
     _check_contains_na,
-    _check_input_matches_training_df,
-    _is_dataframe,
+    _check_X_matches_training_df,
+    check_X,
 )
 from feature_engine.docstrings import (
     Substitution,
@@ -20,7 +20,7 @@ from feature_engine.docstrings import (
     _missing_values_docstring,
     _n_features_in_docstring,
 )
-from feature_engine.validation import _return_tags
+from feature_engine.tags import _return_tags
 from feature_engine.variable_manipulation import _find_or_check_numerical_variables
 
 
@@ -213,7 +213,7 @@ class MathematicalCombination(BaseEstimator, TransformerMixin):
         """
 
         # check input dataframe
-        X = _is_dataframe(X)
+        X = check_X(X)
 
         # check variables to combine are numerical
         self.variables_to_combine = _find_or_check_numerical_variables(
@@ -273,10 +273,10 @@ class MathematicalCombination(BaseEstimator, TransformerMixin):
         check_is_fitted(self)
 
         # check that input is a dataframe
-        X = _is_dataframe(X)
+        X = check_X(X)
 
         # Check if input data contains same number of columns as dataframe used to fit.
-        _check_input_matches_training_df(X, self.n_features_in_)
+        _check_X_matches_training_df(X, self.n_features_in_)
 
         # check if dataset contains na
         if self.missing_values == "raise":
diff --git a/feature_engine/dataframe_checks.py b/feature_engine/dataframe_checks.py
index efb210a..b85d415 100644
--- a/feature_engine/dataframe_checks.py
+++ b/feature_engine/dataframe_checks.py
@@ -9,52 +9,83 @@ import pandas as pd
 from scipy.sparse import issparse
 
 
-def _is_dataframe(X: pd.DataFrame) -> pd.DataFrame:
+def check_X(X: Union[np.generic, np.ndarray, pd.DataFrame]) -> pd.DataFrame:
     """
-    Checks if the input is a DataFrame and then creates a copy.
+    Checks if the input is a DataFrame and then creates a copy. This is an important
+    step not to accidentally transform the original dataset entered by the user.
 
-    If the input is a numpy array, it converts it to a pandas Dataframe. This is mostly
-    so that we can add the check_estimator checks for compatibility with sklearn.
+    If the input is a numpy array, it converts it to a pandas Dataframe. The column
+    names are strings representing the column index starting at 0.
+
+    Feature-engine was originally designed to work with pandas dataframes. However,
+    allowing numpy arrays as input allows 2 things:
+
+    We can use the Scikit-learn tests for transformers provided by the
+    `check_estimator` function to test the compatibility of our transformers with
+    sklearn functionality.
+
+    Feature-engine transformers can be used within a Scikit-learn Pipeline together
+    with Scikit-learn transformers like the `SimpleImputer`, which return by default
+    Numpy arrays.
 
     Parameters
     ----------
-    X : pandas Dataframe or numpy array. The one that will be checked and copied.
+    X : pandas Dataframe or numpy array.
+        The input to check and copy or transform.
 
     Raises
     ------
     TypeError
-        If the input is not a Pandas DataFrame or a numpy array
+        If the input is not a Pandas DataFrame or a numpy array.
+    ValueError
+        If the input is an empty dataframe.
 
     Returns
     -------
     X : pandas Dataframe.
-        A copy of original DataFrame. Important step not to accidentally transform the
-        original dataset entered by the user.
+        A copy of original DataFrame or a converted Numpy array.
     """
-    # check_estimator uses numpy arrays for its checks.
-    # Thus, we need to allow np arrays
-    if isinstance(X, (np.generic, np.ndarray)):
-        col_names = [str(i) for i in range(X.shape[1])]
-        X = pd.DataFrame(X, columns=col_names)
-
-    if issparse(X):
-        raise ValueError("This transformer does not support sparse matrices.")
-
-    if not isinstance(X, pd.DataFrame):
+    if isinstance(X, pd.DataFrame):
+        X = X.copy()
+
+    elif isinstance(X, (np.generic, np.ndarray)):
+        # If input is scalar raise error
+        if X.ndim == 0:
+            raise ValueError(
+                "Expected 2D array, got scalar array instead:\narray={}.\n"
+                "Reshape your data either using array.reshape(-1, 1) if "
+                "your data has a single feature or array.reshape(1, -1) "
+                "if it contains a single sample.".format(X)
+            )
+        # If input is 1D raise error
+        if X.ndim == 1:
+            raise ValueError(
+                "Expected 2D array, got 1D array instead:\narray={}.\n"
+                "Reshape your data either using array.reshape(-1, 1) if "
+                "your data has a single feature or array.reshape(1, -1) "
+                "if it contains a single sample.".format(X)
+            )
+
+        X = pd.DataFrame(X)
+        X.columns = [str(i) for i in range(X.shape[1])]
+
+    elif issparse(X):
+        raise TypeError("This transformer does not support sparse matrices.")
+
+    else:
         raise TypeError(
-            "X is not a pandas dataframe. The dataset should be a pandas dataframe."
+            f"X must be a numpy array or pandas dataframe. Got {type(X)} instead."
         )
 
     if X.empty:
         raise ValueError(
-            "0 feature(s) (shape=%s) while a minimum of %d is "
-            "required." % (X.shape, 1)
+            "0 feature(s) (shape=%s) while a minimum of %d is required." % (X.shape, 1)
         )
 
-    return X.copy()
+    return X
 
 
-def _check_input_matches_training_df(X: pd.DataFrame, reference: int) -> None:
+def _check_X_matches_training_df(X: pd.DataFrame, reference: int) -> None:
     """
     Checks that DataFrame to transform has the same number of columns that the
     DataFrame used with the fit() method.
diff --git a/feature_engine/datetime/datetime.py b/feature_engine/datetime/datetime.py
index c57808a..93d3499 100644
--- a/feature_engine/datetime/datetime.py
+++ b/feature_engine/datetime/datetime.py
@@ -10,8 +10,8 @@ from sklearn.utils.validation import check_is_fitted
 
 from feature_engine.dataframe_checks import (
     _check_contains_na,
-    _check_input_matches_training_df,
-    _is_dataframe,
+    _check_X_matches_training_df,
+    check_X,
 )
 from feature_engine.datetime._datetime_constants import (
     FEATURES_DEFAULT,
@@ -214,7 +214,7 @@ class DatetimeFeatures(BaseEstimator, TransformerMixin):
             It is not needed in this transformer. You can pass y or None.
         """
         # check input dataframe
-        X = _is_dataframe(X)
+        X = check_X(X)
 
         # special case index
         if self.variables == "index":
@@ -274,10 +274,10 @@ class DatetimeFeatures(BaseEstimator, TransformerMixin):
         check_is_fitted(self)
 
         # check that input is a dataframe
-        X = _is_dataframe(X)
+        X = check_X(X)
 
         # Check if input data contains same number of columns as dataframe used to fit.
-        _check_input_matches_training_df(X, self.n_features_in_)
+        _check_X_matches_training_df(X, self.n_features_in_)
 
         # reorder variables to match train set
         X = X[self.feature_names_in_]
diff --git a/feature_engine/discretisation/arbitrary.py b/feature_engine/discretisation/arbitrary.py
index 569f3e3..791e288 100644
--- a/feature_engine/discretisation/arbitrary.py
+++ b/feature_engine/discretisation/arbitrary.py
@@ -15,7 +15,7 @@ from feature_engine.docstrings import (
     _n_features_in_docstring,
     _variables_attribute_docstring,
 )
-from feature_engine.validation import _return_tags
+from feature_engine.tags import _return_tags
 
 
 @Substitution(
diff --git a/feature_engine/discretisation/decision_tree.py b/feature_engine/discretisation/decision_tree.py
index d2b8b6f..b4fb9ad 100644
--- a/feature_engine/discretisation/decision_tree.py
+++ b/feature_engine/discretisation/decision_tree.py
@@ -17,7 +17,7 @@ from feature_engine.docstrings import (
     _variables_attribute_docstring,
     _variables_numerical_docstring,
 )
-from feature_engine.validation import _return_tags
+from feature_engine.tags import _return_tags
 from feature_engine.variable_manipulation import _check_input_parameter_variables
 
 
diff --git a/feature_engine/encoding/base_encoder.py b/feature_engine/encoding/base_encoder.py
index 2645a56..2bb15a6 100644
--- a/feature_engine/encoding/base_encoder.py
+++ b/feature_engine/encoding/base_encoder.py
@@ -7,8 +7,8 @@ from sklearn.utils.validation import check_is_fitted
 
 from feature_engine.dataframe_checks import (
     _check_contains_na,
-    _check_input_matches_training_df,
-    _is_dataframe,
+    _check_X_matches_training_df,
+    check_X,
 )
 from feature_engine.docstrings import Substitution
 from feature_engine.encoding._docstrings import (
@@ -16,7 +16,7 @@ from feature_engine.encoding._docstrings import (
     _ignore_format_docstring,
     _variables_docstring,
 )
-from feature_engine.validation import _return_tags
+from feature_engine.tags import _return_tags
 from feature_engine.variable_manipulation import (
     _check_input_parameter_variables,
     _find_all_variables,
@@ -81,7 +81,7 @@ class BaseCategoricalTransformer(BaseEstimator, TransformerMixin):
         """
 
         # check input dataframe
-        X = _is_dataframe(X)
+        X = check_X(X)
 
         if not self.ignore_format:
             # find categorical variables or check variables entered by user are object
@@ -130,10 +130,10 @@ class BaseCategoricalTransformer(BaseEstimator, TransformerMixin):
         check_is_fitted(self)
 
         # check that input is a dataframe
-        X = _is_dataframe(X)
+        X = check_X(X)
 
         # Check input data contains same number of columns as df used to fit
-        _check_input_matches_training_df(X, self.n_features_in_)
+        _check_X_matches_training_df(X, self.n_features_in_)
 
         # check if dataset contains na
         _check_contains_na(X, self.variables_)
diff --git a/feature_engine/encoding/decision_tree.py b/feature_engine/encoding/decision_tree.py
index d728a95..82e4604 100644
--- a/feature_engine/encoding/decision_tree.py
+++ b/feature_engine/encoding/decision_tree.py
@@ -21,7 +21,7 @@ from feature_engine.encoding._docstrings import (
 )
 from feature_engine.encoding.base_encoder import BaseCategoricalTransformer
 from feature_engine.encoding.ordinal import OrdinalEncoder
-from feature_engine.validation import _return_tags
+from feature_engine.tags import _return_tags
 
 
 @Substitution(
diff --git a/feature_engine/encoding/probability_ratio.py b/feature_engine/encoding/probability_ratio.py
index 6caaa83..bfc2669 100644
--- a/feature_engine/encoding/probability_ratio.py
+++ b/feature_engine/encoding/probability_ratio.py
@@ -21,7 +21,7 @@ from feature_engine.encoding._docstrings import (
     _variables_docstring,
 )
 from feature_engine.encoding.base_encoder import BaseCategorical
-from feature_engine.validation import _return_tags
+from feature_engine.tags import _return_tags
 
 
 @Substitution(
diff --git a/feature_engine/encoding/woe.py b/feature_engine/encoding/woe.py
index e996bb7..fd32421 100644
--- a/feature_engine/encoding/woe.py
+++ b/feature_engine/encoding/woe.py
@@ -21,7 +21,7 @@ from feature_engine.encoding._docstrings import (
     _variables_docstring,
 )
 from feature_engine.encoding.base_encoder import BaseCategorical
-from feature_engine.validation import _return_tags
+from feature_engine.tags import _return_tags
 
 
 @Substitution(
diff --git a/feature_engine/imputation/arbitrary_number.py b/feature_engine/imputation/arbitrary_number.py
index ec08874..67974c1 100644
--- a/feature_engine/imputation/arbitrary_number.py
+++ b/feature_engine/imputation/arbitrary_number.py
@@ -5,7 +5,7 @@ from typing import List, Optional, Union
 
 import pandas as pd
 
-from feature_engine.dataframe_checks import _is_dataframe
+from feature_engine.dataframe_checks import check_X
 from feature_engine.docstrings import (
     Substitution,
     _feature_names_in_docstring,
@@ -113,7 +113,7 @@ class ArbitraryNumberImputer(BaseImputer):
         """
 
         # check input dataframe
-        X = _is_dataframe(X)
+        X = check_X(X)
 
         # find or check for numerical variables
         # create the imputer dictionary
diff --git a/feature_engine/imputation/base_imputer.py b/feature_engine/imputation/base_imputer.py
index 69e3201..6200155 100644
--- a/feature_engine/imputation/base_imputer.py
+++ b/feature_engine/imputation/base_imputer.py
@@ -4,11 +4,8 @@ import pandas as pd
 from sklearn.base import BaseEstimator, TransformerMixin
 from sklearn.utils.validation import check_is_fitted
 
-from feature_engine.dataframe_checks import (
-    _check_input_matches_training_df,
-    _is_dataframe,
-)
-from feature_engine.validation import _return_tags
+from feature_engine.dataframe_checks import _check_X_matches_training_df, check_X
+from feature_engine.tags import _return_tags
 
 
 class BaseImputer(BaseEstimator, TransformerMixin):
@@ -49,10 +46,10 @@ class BaseImputer(BaseEstimator, TransformerMixin):
         check_is_fitted(self)
 
         # check that input is a dataframe
-        X = _is_dataframe(X)
+        X = check_X(X)
 
         # Check that input df contains same number of columns as df used to fit
-        _check_input_matches_training_df(X, self.n_features_in_)
+        _check_X_matches_training_df(X, self.n_features_in_)
 
         # reorder df to match train set
         X = X[self.feature_names_in_]
diff --git a/feature_engine/imputation/categorical.py b/feature_engine/imputation/categorical.py
index 0c6e0c1..6789444 100644
--- a/feature_engine/imputation/categorical.py
+++ b/feature_engine/imputation/categorical.py
@@ -5,7 +5,7 @@ from typing import List, Optional, Union
 
 import pandas as pd
 
-from feature_engine.dataframe_checks import _is_dataframe
+from feature_engine.dataframe_checks import check_X
 from feature_engine.docstrings import (
     Substitution,
     _feature_names_in_docstring,
@@ -14,7 +14,7 @@ from feature_engine.docstrings import (
     _variables_attribute_docstring,
 )
 from feature_engine.imputation.base_imputer import BaseImputer
-from feature_engine.validation import _return_tags
+from feature_engine.tags import _return_tags
 from feature_engine.variable_manipulation import (
     _check_input_parameter_variables,
     _find_all_variables,
@@ -138,7 +138,7 @@ class CategoricalImputer(BaseImputer):
         """
 
         # check input dataframe
-        X = _is_dataframe(X)
+        X = check_X(X)
 
         # check or select the the right variables
         if not self.ignore_format:
diff --git a/feature_engine/imputation/drop_missing_data.py b/feature_engine/imputation/drop_missing_data.py
index 86f8996..8aea8fe 100644
--- a/feature_engine/imputation/drop_missing_data.py
+++ b/feature_engine/imputation/drop_missing_data.py
@@ -5,7 +5,7 @@ from typing import List, Optional, Union
 
 import pandas as pd
 
-from feature_engine.dataframe_checks import _is_dataframe
+from feature_engine.dataframe_checks import check_X
 from feature_engine.docstrings import (
     Substitution,
     _feature_names_in_docstring,
@@ -13,7 +13,7 @@ from feature_engine.docstrings import (
     _n_features_in_docstring,
 )
 from feature_engine.imputation.base_imputer import BaseImputer
-from feature_engine.validation import _return_tags
+from feature_engine.tags import _return_tags
 from feature_engine.variable_manipulation import (
     _check_input_parameter_variables,
     _find_all_variables,
@@ -125,7 +125,7 @@ class DropMissingData(BaseImputer):
         """
 
         # check input dataframe
-        X = _is_dataframe(X)
+        X = check_X(X)
 
         # find variables for which indicator should be added
         self.variables_ = _find_all_variables(X, self.variables)
diff --git a/feature_engine/imputation/end_tail.py b/feature_engine/imputation/end_tail.py
index e5bf2dc..0d9fe7b 100644
--- a/feature_engine/imputation/end_tail.py
+++ b/feature_engine/imputation/end_tail.py
@@ -5,7 +5,7 @@ from typing import List, Optional, Union
 
 import pandas as pd
 
-from feature_engine.dataframe_checks import _is_dataframe
+from feature_engine.dataframe_checks import check_X
 from feature_engine.docstrings import (
     Substitution,
     _feature_names_in_docstring,
@@ -147,7 +147,7 @@ class EndTailImputer(BaseImputer):
             y is not needed in this imputation. You can pass None or y.
         """
         # check input dataframe
-        X = _is_dataframe(X)
+        X = check_X(X)
 
         # find or check for numerical variables
         self.variables_ = _find_or_check_numerical_variables(X, self.variables)
diff --git a/feature_engine/imputation/mean_median.py b/feature_engine/imputation/mean_median.py
index e51c2fe..e61bbd9 100644
--- a/feature_engine/imputation/mean_median.py
+++ b/feature_engine/imputation/mean_median.py
@@ -5,7 +5,7 @@ from typing import List, Optional, Union
 
 import pandas as pd
 
-from feature_engine.dataframe_checks import _is_dataframe
+from feature_engine.dataframe_checks import check_X
 from feature_engine.docstrings import (
     Substitution,
     _feature_names_in_docstring,
@@ -94,7 +94,7 @@ class MeanMedianImputer(BaseImputer):
         """
 
         # check input dataframe
-        X = _is_dataframe(X)
+        X = check_X(X)
 
         # find or check for numerical variables
         self.variables_ = _find_or_check_numerical_variables(X, self.variables)
diff --git a/feature_engine/imputation/missing_indicator.py b/feature_engine/imputation/missing_indicator.py
index 20647e2..f278934 100644
--- a/feature_engine/imputation/missing_indicator.py
+++ b/feature_engine/imputation/missing_indicator.py
@@ -6,7 +6,7 @@ from typing import List, Optional, Union
 import pandas as pd
 from sklearn.utils.validation import check_is_fitted
 
-from feature_engine.dataframe_checks import _is_dataframe
+from feature_engine.dataframe_checks import check_X
 from feature_engine.docstrings import (
     Substitution,
     _feature_names_in_docstring,
@@ -14,7 +14,7 @@ from feature_engine.docstrings import (
     _n_features_in_docstring,
 )
 from feature_engine.imputation.base_imputer import BaseImputer
-from feature_engine.validation import _return_tags
+from feature_engine.tags import _return_tags
 from feature_engine.variable_manipulation import (
     _check_input_parameter_variables,
     _find_all_variables,
@@ -107,7 +107,7 @@ class AddMissingIndicator(BaseImputer):
         """
 
         # check input dataframe
-        X = _is_dataframe(X)
+        X = check_X(X)
 
         # find variables for which indicator should be added
         self.variables_ = _find_all_variables(X, self.variables)
diff --git a/feature_engine/imputation/random_sample.py b/feature_engine/imputation/random_sample.py
index fd15b7d..fbeb7f0 100644
--- a/feature_engine/imputation/random_sample.py
+++ b/feature_engine/imputation/random_sample.py
@@ -6,7 +6,7 @@ from typing import List, Optional, Union
 import numpy as np
 import pandas as pd
 
-from feature_engine.dataframe_checks import _is_dataframe
+from feature_engine.dataframe_checks import check_X
 from feature_engine.docstrings import (
     Substitution,
     _feature_names_in_docstring,
@@ -15,7 +15,7 @@ from feature_engine.docstrings import (
     _variables_attribute_docstring,
 )
 from feature_engine.imputation.base_imputer import BaseImputer
-from feature_engine.validation import _return_tags
+from feature_engine.tags import _return_tags
 from feature_engine.variable_manipulation import (
     _check_input_parameter_variables,
     _find_all_variables,
@@ -158,7 +158,7 @@ class RandomSampleImputer(BaseImputer):
         """
 
         # check input dataframe
-        X = _is_dataframe(X)
+        X = check_X(X)
 
         # find variables to impute
         self.variables_ = _find_all_variables(X, self.variables)
diff --git a/feature_engine/outliers/artbitrary.py b/feature_engine/outliers/artbitrary.py
index baf299b..2abf6dc 100644
--- a/feature_engine/outliers/artbitrary.py
+++ b/feature_engine/outliers/artbitrary.py
@@ -9,7 +9,7 @@ import pandas as pd
 from feature_engine.dataframe_checks import (
     _check_contains_inf,
     _check_contains_na,
-    _is_dataframe,
+    check_X,
 )
 from feature_engine.docstrings import (
     Substitution,
@@ -22,7 +22,7 @@ from feature_engine.docstrings import (
 )
 from feature_engine.outliers.base_outlier import BaseOutlier
 from feature_engine.parameter_checks import _define_numerical_dict
-from feature_engine.validation import _return_tags
+from feature_engine.tags import _return_tags
 from feature_engine.variable_manipulation import _find_or_check_numerical_variables
 
 
@@ -114,7 +114,7 @@ class ArbitraryOutlierCapper(BaseOutlier):
         y: pandas Series, default=None
             y is not needed in this transformer. You can pass y or None.
         """
-        X = _is_dataframe(X)
+        X = check_X(X)
 
         # find variables to be capped
         if self.min_capping_dict is None and self.max_capping_dict:
diff --git a/feature_engine/outliers/base_outlier.py b/feature_engine/outliers/base_outlier.py
index fe6b208..c014244 100644
--- a/feature_engine/outliers/base_outlier.py
+++ b/feature_engine/outliers/base_outlier.py
@@ -8,10 +8,10 @@ from sklearn.utils.validation import check_is_fitted
 from feature_engine.dataframe_checks import (
     _check_contains_inf,
     _check_contains_na,
-    _check_input_matches_training_df,
-    _is_dataframe,
+    _check_X_matches_training_df,
+    check_X,
 )
-from feature_engine.validation import _return_tags
+from feature_engine.tags import _return_tags
 from feature_engine.variable_manipulation import (
     _check_input_parameter_variables,
     _find_or_check_numerical_variables,
@@ -55,11 +55,11 @@ class BaseOutlier(BaseEstimator, TransformerMixin):
         check_is_fitted(self)
 
         # check that input is a dataframe
-        X = _is_dataframe(X)
+        X = check_X(X)
 
         # Check that the dataframe contains the same number of columns
         # than the dataframe used to fit the imputer.
-        _check_input_matches_training_df(X, self.n_features_in_)
+        _check_X_matches_training_df(X, self.n_features_in_)
 
         if self.missing_values == "raise":
             # check if dataset contains na
@@ -239,7 +239,7 @@ class WinsorizerBase(BaseOutlier):
         """
 
         # check input dataframe
-        X = _is_dataframe(X)
+        X = check_X(X)
 
         # find or check for numerical variables
         self.variables_ = _find_or_check_numerical_variables(X, self.variables)
diff --git a/feature_engine/outliers/winsorizer.py b/feature_engine/outliers/winsorizer.py
index d2304df..6e83480 100644
--- a/feature_engine/outliers/winsorizer.py
+++ b/feature_engine/outliers/winsorizer.py
@@ -6,7 +6,7 @@ from typing import List, Union
 import numpy as np
 import pandas as pd
 
-from feature_engine.dataframe_checks import _is_dataframe
+from feature_engine.dataframe_checks import check_X
 from feature_engine.docstrings import (
     Substitution,
     _feature_names_in_docstring,
@@ -129,7 +129,7 @@ class Winsorizer(WinsorizerBase):
             X_out = super().transform(X)
 
         else:
-            X_orig = _is_dataframe(X)
+            X_orig = check_X(X)
             X_out = super().transform(X_orig)
             X_orig = X_orig[self.variables_]
             X_out_filtered = X_out[self.variables_]
diff --git a/feature_engine/preprocessing/match_columns.py b/feature_engine/preprocessing/match_columns.py
index d179a51..735f9c4 100644
--- a/feature_engine/preprocessing/match_columns.py
+++ b/feature_engine/preprocessing/match_columns.py
@@ -5,8 +5,8 @@ import pandas as pd
 from sklearn.base import BaseEstimator, TransformerMixin
 from sklearn.utils.validation import check_is_fitted
 
-from feature_engine.dataframe_checks import _check_contains_na, _is_dataframe
-from feature_engine.validation import _return_tags
+from feature_engine.dataframe_checks import _check_contains_na, check_X
+from feature_engine.tags import _return_tags
 
 
 class MatchVariables(BaseEstimator, TransformerMixin):
@@ -142,7 +142,7 @@ class MatchVariables(BaseEstimator, TransformerMixin):
         y: None
             y is not needed for this transformer. You can pass y or None.
         """
-        X = _is_dataframe(X)
+        X = check_X(X)
 
         if self.missing_values == "raise":
             # check if dataset contains na
@@ -173,7 +173,7 @@ class MatchVariables(BaseEstimator, TransformerMixin):
         """
         check_is_fitted(self)
 
-        X = _is_dataframe(X)
+        X = check_X(X)
 
         if self.missing_values == "raise":
             # check if dataset contains na
diff --git a/feature_engine/selection/base_recursive_selector.py b/feature_engine/selection/base_recursive_selector.py
index 962cb47..745a710 100644
--- a/feature_engine/selection/base_recursive_selector.py
+++ b/feature_engine/selection/base_recursive_selector.py
@@ -3,9 +3,9 @@ from typing import List, Union
 import pandas as pd
 from sklearn.model_selection import cross_validate
 
-from feature_engine.dataframe_checks import _is_dataframe
+from feature_engine.dataframe_checks import check_X
 from feature_engine.selection.base_selector import BaseSelector, get_feature_importances
-from feature_engine.validation import _return_tags
+from feature_engine.tags import _return_tags
 from feature_engine.variable_manipulation import (
     _check_input_parameter_variables,
     _find_or_check_numerical_variables,
@@ -142,7 +142,7 @@ class BaseRecursiveSelector(BaseSelector):
         """
 
         # check input dataframe
-        X = _is_dataframe(X)
+        X = check_X(X)
 
         # If required exclude variables that are not in the input dataframe
         self._confirm_variables(X)
diff --git a/feature_engine/selection/base_selector.py b/feature_engine/selection/base_selector.py
index 5967b1c..ec97d22 100644
--- a/feature_engine/selection/base_selector.py
+++ b/feature_engine/selection/base_selector.py
@@ -5,11 +5,8 @@ import pandas as pd
 from sklearn.base import BaseEstimator, TransformerMixin
 from sklearn.utils.validation import check_is_fitted
 
-from feature_engine.dataframe_checks import (
-    _check_input_matches_training_df,
-    _is_dataframe,
-)
-from feature_engine.validation import _return_tags
+from feature_engine.dataframe_checks import _check_X_matches_training_df, check_X
+from feature_engine.tags import _return_tags
 from feature_engine.variable_manipulation import _filter_out_variables_not_in_dataframe
 
 
@@ -100,10 +97,10 @@ class BaseSelector(BaseEstimator, TransformerMixin):
         check_is_fitted(self)
 
         # check if input is a dataframe
-        X = _is_dataframe(X)
+        X = check_X(X)
 
         # check if number of columns in test dataset matches to train dataset
-        _check_input_matches_training_df(X, self.n_features_in_)
+        _check_X_matches_training_df(X, self.n_features_in_)
 
         # reorder df to match train set
         X = X[self.feature_names_in_]
diff --git a/feature_engine/selection/drop_constant_features.py b/feature_engine/selection/drop_constant_features.py
index 31395d9..09b82fa 100644
--- a/feature_engine/selection/drop_constant_features.py
+++ b/feature_engine/selection/drop_constant_features.py
@@ -2,7 +2,7 @@ from typing import List, Union
 
 import pandas as pd
 
-from feature_engine.dataframe_checks import _check_contains_na, _is_dataframe
+from feature_engine.dataframe_checks import _check_contains_na, check_X
 from feature_engine.docstrings import (
     Substitution,
     _feature_names_in_docstring,
@@ -14,7 +14,7 @@ from feature_engine.selection._docstring import (
     _variables_attribute_docstring,
 )
 from feature_engine.selection.base_selector import BaseSelector
-from feature_engine.validation import _return_tags
+from feature_engine.tags import _return_tags
 from feature_engine.variable_manipulation import (
     _check_input_parameter_variables,
     _find_all_variables,
@@ -136,7 +136,7 @@ class DropConstantFeatures(BaseSelector):
         """
 
         # check input dataframe
-        X = _is_dataframe(X)
+        X = check_X(X)
 
         # If required exclude variables that are not in the input dataframe
         self._confirm_variables(X)
diff --git a/feature_engine/selection/drop_correlated_features.py b/feature_engine/selection/drop_correlated_features.py
index 2754c03..86f0947 100644
--- a/feature_engine/selection/drop_correlated_features.py
+++ b/feature_engine/selection/drop_correlated_features.py
@@ -5,7 +5,7 @@ import pandas as pd
 from feature_engine.dataframe_checks import (
     _check_contains_inf,
     _check_contains_na,
-    _is_dataframe,
+    check_X,
 )
 from feature_engine.docstrings import (
     Substitution,
@@ -141,7 +141,7 @@ class DropCorrelatedFeatures(BaseSelector):
         """
 
         # check input dataframe
-        X = _is_dataframe(X)
+        X = check_X(X)
 
         # If required exclude variables that are not in the input dataframe
         self._confirm_variables(X)
diff --git a/feature_engine/selection/drop_duplicate_features.py b/feature_engine/selection/drop_duplicate_features.py
index bc3f07d..c034b0e 100644
--- a/feature_engine/selection/drop_duplicate_features.py
+++ b/feature_engine/selection/drop_duplicate_features.py
@@ -2,7 +2,7 @@ from typing import List, Union
 
 import pandas as pd
 
-from feature_engine.dataframe_checks import _check_contains_na, _is_dataframe
+from feature_engine.dataframe_checks import _check_contains_na, check_X
 from feature_engine.docstrings import (
     Substitution,
     _feature_names_in_docstring,
@@ -15,7 +15,7 @@ from feature_engine.selection._docstring import (
     _variables_attribute_docstring,
 )
 from feature_engine.selection.base_selector import BaseSelector
-from feature_engine.validation import _return_tags
+from feature_engine.tags import _return_tags
 from feature_engine.variable_manipulation import (
     _check_input_parameter_variables,
     _find_all_variables,
@@ -112,7 +112,7 @@ class DropDuplicateFeatures(BaseSelector):
         """
 
         # check input dataframe
-        X = _is_dataframe(X)
+        X = check_X(X)
 
         # If required exclude variables that are not in the input dataframe
         self._confirm_variables(X)
diff --git a/feature_engine/selection/drop_features.py b/feature_engine/selection/drop_features.py
index 21c3fbf..02b2400 100644
--- a/feature_engine/selection/drop_features.py
+++ b/feature_engine/selection/drop_features.py
@@ -2,9 +2,9 @@ from typing import List, Union
 
 import pandas as pd
 
-from feature_engine.dataframe_checks import _is_dataframe
+from feature_engine.dataframe_checks import check_X
 from feature_engine.selection.base_selector import BaseSelector
-from feature_engine.validation import _return_tags
+from feature_engine.tags import _return_tags
 
 
 class DropFeatures(BaseSelector):
@@ -72,7 +72,7 @@ class DropFeatures(BaseSelector):
             y is not needed for this transformer. You can pass y or None.
         """
         # check input dataframe
-        X = _is_dataframe(X)
+        X = check_X(X)
 
         # X[self.features_to_drops] calls to pandas to check if columns are
         # present in the df.
diff --git a/feature_engine/selection/drop_psi_features.py b/feature_engine/selection/drop_psi_features.py
index 114e50f..1a05ddf 100644
--- a/feature_engine/selection/drop_psi_features.py
+++ b/feature_engine/selection/drop_psi_features.py
@@ -8,7 +8,7 @@ from pandas.api.types import is_numeric_dtype
 from feature_engine.dataframe_checks import (
     _check_contains_inf,
     _check_contains_na,
-    _is_dataframe,
+    check_X,
 )
 from feature_engine.discretisation import (
     EqualFrequencyDiscretiser,
@@ -309,7 +309,7 @@ class DropHighPSIFeatures(BaseSelector):
             y is not needed in this transformer. You can pass y or None.
         """
         # check input dataframe
-        X = _is_dataframe(X)
+        X = check_X(X)
 
         # If required exclude variables that are not in the input dataframe
         self._confirm_variables(X)
diff --git a/feature_engine/selection/shuffle_features.py b/feature_engine/selection/shuffle_features.py
index 6c44ed2..b078b91 100644
--- a/feature_engine/selection/shuffle_features.py
+++ b/feature_engine/selection/shuffle_features.py
@@ -7,7 +7,7 @@ from sklearn.metrics import get_scorer
 from sklearn.model_selection import check_cv, cross_validate
 from sklearn.utils.validation import check_random_state
 
-from feature_engine.dataframe_checks import _is_dataframe
+from feature_engine.dataframe_checks import check_X
 from feature_engine.docstrings import (
     Substitution,
     _feature_names_in_docstring,
@@ -27,7 +27,7 @@ from feature_engine.selection._docstring import (
     _variables_numerical_docstring,
 )
 from feature_engine.selection.base_selector import BaseSelector
-from feature_engine.validation import _return_tags
+from feature_engine.tags import _return_tags
 from feature_engine.variable_manipulation import (
     _check_input_parameter_variables,
     _find_or_check_numerical_variables,
@@ -163,7 +163,7 @@ class SelectByShuffling(BaseSelector):
         """
 
         # check input dataframe
-        X = _is_dataframe(X)
+        X = check_X(X)
 
         # reset the index
         X = X.reset_index(drop=True)
diff --git a/feature_engine/selection/single_feature_performance.py b/feature_engine/selection/single_feature_performance.py
index 01b204f..5c44dd5 100644
--- a/feature_engine/selection/single_feature_performance.py
+++ b/feature_engine/selection/single_feature_performance.py
@@ -4,7 +4,7 @@ from typing import List, Union
 import pandas as pd
 from sklearn.model_selection import cross_validate
 
-from feature_engine.dataframe_checks import _is_dataframe
+from feature_engine.dataframe_checks import check_X
 from feature_engine.docstrings import (
     Substitution,
     _feature_names_in_docstring,
@@ -24,7 +24,7 @@ from feature_engine.selection._docstring import (
     _variables_numerical_docstring,
 )
 from feature_engine.selection.base_selector import BaseSelector
-from feature_engine.validation import _return_tags
+from feature_engine.tags import _return_tags
 from feature_engine.variable_manipulation import (
     _check_input_parameter_variables,
     _find_or_check_numerical_variables,
@@ -156,7 +156,7 @@ class SelectBySingleFeaturePerformance(BaseSelector):
         """
 
         # check input dataframe
-        X = _is_dataframe(X)
+        X = check_X(X)
 
         # If required exclude variables that are not in the input dataframe
         self._confirm_variables(X)
diff --git a/feature_engine/selection/smart_correlation_selection.py b/feature_engine/selection/smart_correlation_selection.py
index b6234b4..1840d7b 100644
--- a/feature_engine/selection/smart_correlation_selection.py
+++ b/feature_engine/selection/smart_correlation_selection.py
@@ -6,7 +6,7 @@ from sklearn.model_selection import cross_validate
 from feature_engine.dataframe_checks import (
     _check_contains_inf,
     _check_contains_na,
-    _is_dataframe,
+    check_X,
 )
 from feature_engine.docstrings import (
     Substitution,
@@ -214,7 +214,7 @@ class SmartCorrelatedSelection(BaseSelector):
         """
 
         # check input dataframe
-        X = _is_dataframe(X)
+        X = check_X(X)
 
         # If required exclude variables that are not in the input dataframe
         self._confirm_variables(X)
diff --git a/feature_engine/selection/target_mean_selection.py b/feature_engine/selection/target_mean_selection.py
index a1267f4..26d2693 100644
--- a/feature_engine/selection/target_mean_selection.py
+++ b/feature_engine/selection/target_mean_selection.py
@@ -6,7 +6,7 @@ from sklearn.model_selection import cross_validate
 
 from feature_engine._prediction.target_mean_classifier import TargetMeanClassifier
 from feature_engine._prediction.target_mean_regressor import TargetMeanRegressor
-from feature_engine.dataframe_checks import _is_dataframe
+from feature_engine.dataframe_checks import check_X
 from feature_engine.docstrings import (
     Substitution,
     _feature_names_in_docstring,
@@ -27,7 +27,7 @@ from feature_engine.selection._selection_constants import (
     _REGRESSION_METRICS,
 )
 from feature_engine.selection.base_selector import BaseSelector
-from feature_engine.validation import _return_tags
+from feature_engine.tags import _return_tags
 from feature_engine.variable_manipulation import (
     _check_input_parameter_variables,
     _find_all_variables,
@@ -224,7 +224,7 @@ class SelectByTargetMeanPerformance(BaseSelector):
            Target variable. Required to train the estimator.
         """
         # check input dataframe
-        X = _is_dataframe(X)
+        X = check_X(X)
 
         # If required exclude variables that are not in the input dataframe
         self._confirm_variables(X)
diff --git a/feature_engine/validation.py b/feature_engine/tags.py
similarity index 84%
rename from feature_engine/validation.py
rename to feature_engine/tags.py
index ec8c7f8..4b8f518 100644
--- a/feature_engine/validation.py
+++ b/feature_engine/tags.py
@@ -3,9 +3,8 @@ def _return_tags():
         "_xfail_checks": {
             # Complex data in math terms, are values like 4i (imaginary numbers
             # so to speak). I've never seen such a thing in the dfs I've
-            # worked with, so I dont need this test.
-            "check_complex_data": "I dont think we need this check, if users "
-            "disagree we can think how to introduce it at a later stage.",
+            # worked with, so I don't think we need this test.
+            "check_complex_data": "Test not needed.",
             # check that estimators treat dtype object as numeric if possible
             "check_dtype_object": "Feature-engine transformers use dtypes to select "
             "between numerical and categorical variables. Feature-engine trusts the "
@@ -25,8 +24,6 @@ def _return_tags():
             # the test below tests that a second fit overrides a first fit.
             # the problem is that the test does not work with pandas df.
             "check_fit_idempotent": "Test does not work on dataframes",
-            "check_fit1d": "Test not relevant, Feature-engine transformers only"
-            "work with dataframes",
             "check_fit2d_predict1d": "Test not relevant, Feature-engine transformers "
             "only work with dataframes",
         }
diff --git a/feature_engine/timeseries/forecasting/base_forecast_transformers.py b/feature_engine/timeseries/forecasting/base_forecast_transformers.py
index 40715a2..771538a 100644
--- a/feature_engine/timeseries/forecasting/base_forecast_transformers.py
+++ b/feature_engine/timeseries/forecasting/base_forecast_transformers.py
@@ -7,8 +7,8 @@ from sklearn.utils.validation import check_is_fitted
 from feature_engine.dataframe_checks import (
     _check_contains_inf,
     _check_contains_na,
-    _check_input_matches_training_df,
-    _is_dataframe,
+    _check_X_matches_training_df,
+    check_X,
 )
 from feature_engine.docstrings import (
     Substitution,
@@ -18,7 +18,7 @@ from feature_engine.docstrings import (
     _missing_values_docstring,
     _n_features_in_docstring,
 )
-from feature_engine.validation import _return_tags
+from feature_engine.tags import _return_tags
 from feature_engine.variable_manipulation import (
     _check_input_parameter_variables,
     _find_or_check_numerical_variables,
@@ -143,7 +143,7 @@ class BaseForecastTransformer(BaseEstimator, TransformerMixin):
             y is not needed in this transformer. You can pass None or y.
         """
         # check input dataframe
-        X = _is_dataframe(X)
+        X = check_X(X)
 
         # We need the dataframes to have unique values in the index and no missing data.
         # Otherwise, when we merge the new features we will duplicate rows.
@@ -178,11 +178,11 @@ class BaseForecastTransformer(BaseEstimator, TransformerMixin):
         check_is_fitted(self)
 
         # check if 'X' is a dataframe
-        X = _is_dataframe(X)
+        X = check_X(X)
 
         # check if input data contains the same number of columns as the fitted
         # dataframe.
-        _check_input_matches_training_df(X, self.n_features_in_)
+        _check_X_matches_training_df(X, self.n_features_in_)
 
         # Dataframes must have unique values in the index and no missing data.
         # Otherwise, when we merge the created features we will duplicate rows.
diff --git a/feature_engine/transformation/boxcox.py b/feature_engine/transformation/boxcox.py
index 5560145..0700d2a 100644
--- a/feature_engine/transformation/boxcox.py
+++ b/feature_engine/transformation/boxcox.py
@@ -15,7 +15,7 @@ from feature_engine.docstrings import (
     _variables_attribute_docstring,
     _variables_numerical_docstring,
 )
-from feature_engine.validation import _return_tags
+from feature_engine.tags import _return_tags
 from feature_engine.variable_manipulation import _check_input_parameter_variables
 
 
diff --git a/feature_engine/transformation/log.py b/feature_engine/transformation/log.py
index e8078eb..72f9937 100644
--- a/feature_engine/transformation/log.py
+++ b/feature_engine/transformation/log.py
@@ -17,7 +17,7 @@ from feature_engine.docstrings import (
     _variables_attribute_docstring,
     _variables_numerical_docstring,
 )
-from feature_engine.validation import _return_tags
+from feature_engine.tags import _return_tags
 from feature_engine.variable_manipulation import _check_input_parameter_variables
 
 
diff --git a/feature_engine/transformation/reciprocal.py b/feature_engine/transformation/reciprocal.py
index 59b1396..eac8356 100644
--- a/feature_engine/transformation/reciprocal.py
+++ b/feature_engine/transformation/reciprocal.py
@@ -17,7 +17,7 @@ from feature_engine.docstrings import (
     _variables_attribute_docstring,
     _variables_numerical_docstring,
 )
-from feature_engine.validation import _return_tags
+from feature_engine.tags import _return_tags
 from feature_engine.variable_manipulation import _check_input_parameter_variables
 
 
diff --git a/feature_engine/transformation/yeojohnson.py b/feature_engine/transformation/yeojohnson.py
index 93ca41f..43e3731 100644
--- a/feature_engine/transformation/yeojohnson.py
+++ b/feature_engine/transformation/yeojohnson.py
@@ -98,9 +98,6 @@ class YeoJohnsonTransformer(BaseNumericalTransformer):
 
         self.lambda_dict_ = {}
 
-        # to avoid NumPy error
-        X[self.variables_] = X[self.variables_].astype("float")
-
         for var in self.variables_:
             _, self.lambda_dict_[var] = stats.yeojohnson(X[var])
 
diff --git a/feature_engine/wrappers/wrappers.py b/feature_engine/wrappers/wrappers.py
index a2c5993..fcbc718 100644
--- a/feature_engine/wrappers/wrappers.py
+++ b/feature_engine/wrappers/wrappers.py
@@ -4,11 +4,8 @@ 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_input_matches_training_df,
-    _is_dataframe,
-)
-from feature_engine.validation import _return_tags
+from feature_engine.dataframe_checks import _check_X_matches_training_df, check_X
+from feature_engine.tags import _return_tags
 from feature_engine.variable_manipulation import (
     _check_input_parameter_variables,
     _find_all_variables,
@@ -211,7 +208,7 @@ class SklearnTransformerWrapper(BaseEstimator, TransformerMixin):
         """
 
         # check input dataframe
-        X = _is_dataframe(X)
+        X = check_X(X)
 
         self.transformer_ = clone(self.transformer)
 
@@ -266,12 +263,12 @@ class SklearnTransformerWrapper(BaseEstimator, TransformerMixin):
         check_is_fitted(self)
 
         # check that input is a dataframe
-        X = _is_dataframe(X)
+        X = check_X(X)
 
         # Check that input data contains same number of columns than
         # the dataframe used to fit the imputer.
 
-        _check_input_matches_training_df(X, self.n_features_in_)
+        _check_X_matches_training_df(X, self.n_features_in_)
 
         # reorder df to match train set
         X = X[self.feature_names_in_]
@@ -325,7 +322,7 @@ class SklearnTransformerWrapper(BaseEstimator, TransformerMixin):
         check_is_fitted(self)
 
         # check that input is a dataframe
-        X = _is_dataframe(X)
+        X = check_X(X)
 
         if self.transformer_.__class__.__name__ not in _INVERSE_TRANSFORM:
             raise NotImplementedError(


Test patch:
diff --git a/tests/test_dataframe_checks.py b/tests/test_dataframe_checks.py
index 396cefc..6ed8472 100644
--- a/tests/test_dataframe_checks.py
+++ b/tests/test_dataframe_checks.py
@@ -1,24 +1,58 @@
+import numpy as np
+import pandas as pd
 import pytest
 from pandas.testing import assert_frame_equal
+from scipy.sparse import csr_matrix
 
 from feature_engine.dataframe_checks import (
+    _check_contains_inf,
     _check_contains_na,
-    _check_input_matches_training_df,
-    _is_dataframe,
+    _check_X_matches_training_df,
+    check_X,
 )
 
 
-def test_is_dataframe(df_vartypes):
-    assert_frame_equal(_is_dataframe(df_vartypes), df_vartypes)
+def test_check_X_returns_df(df_vartypes):
+    assert_frame_equal(check_X(df_vartypes), df_vartypes)
+
+
+def test_check_X_converts_numpy_to_pandas():
+    a1D = np.array([1, 2, 3, 4])
+    a2D = np.array([[1, 2], [3, 4]])
+    a3D = np.array([[[1, 2], [3, 4]], [[5, 6], [7, 8]]])
+
+    df_2D = pd.DataFrame(a2D, columns=["0", "1"])
+    assert_frame_equal(df_2D, check_X(a2D))
+
+    with pytest.raises(ValueError):
+        check_X(a3D)
+    with pytest.raises(ValueError):
+        check_X(a1D)
+
+
+def test_check_X_raises_error_sparse_matrix():
+    sparse_mx = csr_matrix([[5]])
     with pytest.raises(TypeError):
-        assert _is_dataframe([1, 2, 4])
+        assert check_X(sparse_mx)
+
+
+def test_raises_error_if_empty_df():
+    df = pd.DataFrame([])
+    with pytest.raises(ValueError):
+        check_X(df)
 
 
-def test_check_input_matches_training_df(df_vartypes):
+def test_check_X_matches_training_df(df_vartypes):
     with pytest.raises(ValueError):
-        assert _check_input_matches_training_df(df_vartypes, 4)
+        assert _check_X_matches_training_df(df_vartypes, 4)
 
 
 def test_contains_na(df_na):
     with pytest.raises(ValueError):
         assert _check_contains_na(df_na, ["Name", "City"])
+
+
+def test_contains_inf(df_na):
+    df_na.fillna(np.inf, inplace=True)
+    with pytest.raises(ValueError):
+        assert _check_contains_inf(df_na, ["Age", "Marks"])
diff --git a/tests/test_datetime/test_check_estimator_datetime.py b/tests/test_datetime/test_check_estimator_datetime.py
index f424ac6..0d71fdd 100644
--- a/tests/test_datetime/test_check_estimator_datetime.py
+++ b/tests/test_datetime/test_check_estimator_datetime.py
@@ -1,4 +1,5 @@
 import pytest
+
 from feature_engine.datetime import DatetimeFeatures
 from feature_engine.estimator_checks import check_feature_engine_estimator
 
diff --git a/tests/test_transformation/test_yeojohnson_transformer.py b/tests/test_transformation/test_yeojohnson_transformer.py
index 3e9179c..ae884bf 100644
--- a/tests/test_transformation/test_yeojohnson_transformer.py
+++ b/tests/test_transformation/test_yeojohnson_transformer.py
@@ -24,6 +24,47 @@ def test_automatically_select_variables(df_vartypes):
     pd.testing.assert_frame_equal(X, transf_df)
 
 
+def test_transformer_on_integer_variables():
+    df = pd.DataFrame(
+        {
+            "var1": [0, 1, 0, 2, 3, 4, 5, 6, 8, 10],
+            "var2": [12, 11, 10, 15, 13, 12, 11, 10, 10, 20],
+        }
+    )
+
+    dft = pd.DataFrame(
+        {
+            "var1": {
+                0: 0.0,
+                1: 0.7871467037957388,
+                2: 0.0,
+                3: 1.34716625120788,
+                4: 1.797027857352365,
+                5: 2.1794549065159363,
+                6: 2.5155129679774246,
+                7: 2.817344570368886,
+                8: 3.346739213848269,
+                9: 3.8051709334268566,
+            },
+            "var2": {
+                0: 0.2891005444159968,
+                1: 0.2890875957028113,
+                2: 0.2890687942494933,
+                3: 0.2891213447054929,
+                4: 0.2891097235906253,
+                5: 0.2891005444159968,
+                6: 0.2890875957028113,
+                7: 0.2890687942494933,
+                8: 0.2890687942494933,
+                9: 0.28913341330818815,
+            },
+        }
+    )
+
+    X_tr = YeoJohnsonTransformer().fit_transform(df)
+    pd.testing.assert_frame_equal(X_tr, dft)
+
+
 def test_fit_raises_error_if_na_in_df(df_na):
     # test case 2: when dataset contains na, fit method
     with pytest.raises(ValueError):