I have a pandas dataframe test_df. This dataframe contains 20 columns. I am given a list of column index col_index = [3, 5] for example.
I need to create two separate dataframes
- one only including the columns in col_index
- other includes all the columns except the columns in col_index
How do I do that?
I understand I can do
new_df = df.iloc[:, 3]
To create a dataframe out of column number 3. But what do I do as in this case I have multiple column numbers to separate out from the main dataframe?
Using python 3