find_all_variables#

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

Returns a list with the names of all the variables in the dataframe. Optionally, it exlcudes variables that can be parsed as datetime or datetimetz.

More details in the User Guide.

Parameters
Xpandas dataframe of shape = [n_samples, n_features]

The dataset.

exclude_datetime: bool, default=False

Whether to exclude datetime variables.

return_emptybool, default=False

Whether to return an empty list when no variables are found. If False, the function raises an error.

Returns
variables: List

The names of the variables.

Examples

>>> 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]]