Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8215327
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T11:44:55+00:00 2026-06-07T11:44:55+00:00

Given a DataFrame that contains multiple columns (possible regressors), how can I generate all

  • 0

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
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T11:44:57+00:00Added an answer on June 7, 2026 at 11:44 am

    Try using itertools to generate the powerset of column names:

    In [23]: import itertools as iter
    
    In [24]: def pset(lst):
       ....:     comb = (iter.combinations(lst, l) for l in range(len(lst) + 1))
       ....:     return list(iter.chain.from_iterable(comb))
       ....: 
    
    
    In [25]: pset(lst)
    Out[25]: 
    [(),
     ('A',),
     ('B',),
     ('C',),
     ('D',),
     ('A', 'B'),
     ('A', 'C'),
     ('A', 'D'),
     ('B', 'C'),
     ('B', 'D'),
     ('C', 'D'),
     ('A', 'B', 'C'),
     ('A', 'B', 'D'),
     ('A', 'C', 'D'),
     ('B', 'C', 'D'),
     ('A', 'B', 'C', 'D')]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'd like to combine multiple columns of a data frame in R. Given data
Given that you have a data frame with a lot of columns and rows,
Can somebody point me to some reading on some algorithm that given a set
I have a column in a dataframe that contains an ordered factor. I summarize
Given that the web application doesn't have su privileges, I'd like to execute a
Given a MySQL table of real estate data, I would like to generate a
So, I was given an Ada 95 program, and the assembly code that the
I have some data in a dataframe calvarbyruno.1 with variables Nominal and PAR that
I usually work with big dataframes that are pretty well sorted (or can be
I want to convert a column of my dataframe into another one. I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.