If you have a list of columns you can just select those:
In [11]: df
Out[11]:
1 2 3 4 5 6
A x x x x x x
B x x x x x x
C x x x x x x
In [12]: col_list = [3, 5]
In [13]: df = df[col_list]
In [14]: df
Out[14]:
3 5
A x x
B x x
C x x
Related Contents:
- How to replace NaN values by Zeroes in a column of a Pandas Dataframe?
- How to avoid pandas creating an index in a saved csv
- Sorting columns in pandas dataframe based on column name [duplicate]
- What does axis in pandas mean?
- Update a dataframe in pandas while iterating row by row
- How to print pandas DataFrame without index
- pandas three-way joining multiple dataframes on columns
- Progress indicator during pandas operations
- How can I map True/False to 1/0 in a Pandas DataFrame?
- add a string prefix to each value in a string column using Pandas
- pandas dataframe columns scaling with sklearn
- How to read a .xlsx file using the pandas Library in iPython?
- Concatenate strings from several rows using Pandas groupby
- Find maximum value of a column and return the corresponding row values using Pandas
- How to get a value from a Pandas DataFrame and not the index and object type
- How to add value labels on a bar chart
- Are for-loops in pandas really bad? When should I care?
- Pandas groupby: How to get a union of strings
- How to use sklearn fit_transform with pandas and return dataframe instead of numpy array?
- Pandas: filling missing values by mean in each group
- How to print a specific row of a pandas DataFrame?
- How to remove timezone from a Timestamp column in a pandas dataframe
- Converting between datetime and Pandas Timestamp objects
- Concatenate rows of two dataframes in pandas
- Lambda including if…elif…else
- Is there a way to copy only the structure (not the data) of a Pandas DataFrame?
- How can I compute a histogram (frequency table) for a single Series?
- Pyspark: display a spark data frame in a table format
- Pandas concat yields ValueError: Plan shapes are not aligned
- Creating an element-wise minimum Series from two other Series in Python Pandas
- Count occurrences of False or True in a column in pandas
- ValueError: Grouper for not 1-dimensional
- HDF5 – concurrency, compression & I/O performance [closed]
- How to update values in a specific row in a Python Pandas DataFrame?
- Change main plot legend label text
- Panda’s Write CSV – Append vs. Write
- Plotting grouped data in same plot using Pandas
- Efficiently select rows that match one of several values in Pandas DataFrame [duplicate]
- Fillna in multiple columns in place in Python Pandas
- forward fill specific columns in pandas dataframe
- Normalize rows of pandas data frame by their sums [duplicate]
- Pandas Resampling error: Only valid with DatetimeIndex, TimedeltaIndex or PeriodIndex
- How to calculate mean values grouped on another column
- ValueError: Mime type rendering requires nbformat>=4.2.0 but it is not installed
- How to preview a part of a large pandas DataFrame, in iPython notebook?
- Selection with .loc in python
- Pandas – Replace values based on index
- Reversing ‘one-hot’ encoding in Pandas
- How to remove decimal points in pandas
- pandas json_normalize with very nested json