Given a DataFrame that contains multiple columns (possible regressors), how can I generate all possible combinations of columns to test them into different regressions? I’m trying to select the best regression model from all the possible combination of regressors.
For example, I have this DataFrame:
A B
1/1/2011 1 4
1/2/2011 2 5
1/3/2011 3 6
and I want to generate the following ones:
A B
1/1/2011 1 4
1/2/2011 2 5
1/3/2011 3 6
A
1/1/2011 1
1/2/2011 2
1/3/2011 3
B
1/1/2011 4
1/2/2011 5
1/3/2011 6
Try using itertools to generate the powerset of column names: