feature_engine.variable_handling.find_or_check_numerical_variables(X, variables=None)[source]#

Returns the names of all the numerical variables in a dataframe. Alternatively, it checks that the variables entered by the user are numerical.

More details in the User Guide.

Xpandas dataframe of shape = [n_samples, n_features]

The dataset

variableslist, default=None

If None, the function will return the names of all numerical variables in X. Alternatively, it checks that the variables in the list are of type numerical.

variables: List

The names of the numerical variables.


>>> import pandas as pd
>>> from feature_engine.variable_handling import find_or_check_numerical_variables
>>> X = pd.DataFrame({
>>>     "var_num": [1, 2, 3],
>>>     "var_cat": ["A", "B", "C"],
>>>     "var_date": pd.date_range("2020-02-24", periods=3, freq="T")
>>> })
>>> var_num = find_or_check_numerical_variables(X)
>>> var_num


Return type

List[Union[str, int]]