feature_engine.variable_handling.find_all_variables(X, variables=None, exclude_datetime=False)[source]#

Returns the names of all the variables in the dataframe in a list. Alternatively, it will check that the variables indicated by the user are in the dataframe.

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 the variables in X. Alternatively, it checks that the variables in the list are present in the dataframe.

exclude_datetime: bool, default=False

Whether to exclude datetime variables.

variables: List

The names of the variables.


>>> import pandas as pd
>>> from feature_engine.variable_handling import find_all_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")
>>> })
>>> vars_all = find_all_variables(X)
>>> vars_all
['var_num', 'var_cat', 'var_date']
Return type

List[Union[str, int]]