Just pass a list of column names to index df:

df[['nnn', 'mmm', 'yyy']]

   nnn  mmm  yyy
0    5    5   10
1    3    4    9
2    7    0    8

If you need to handle non-existent column names in your list, try filtering with df.columns.isin -

df.loc[:, df.columns.isin(['nnn', 'mmm', 'yyy', 'zzzzzz'])]

   yyy  nnn  mmm
0   10    5    5
1    9    3    4
2    8    7    0
Answer from coldspeed95 on Stack Overflow
🌐
Pandas
pandas.pydata.org › docs › reference › api › pandas.DataFrame.filter.html
pandas.DataFrame.filter — pandas 3.0.6 documentation
>>> # select columns by name >>> df.filter(items=["one", "three"]) one three mouse 1 3 rabbit 4 6
Discussions

python - Pandas Dataframe Filtering Columns and return column name - Stack Overflow
How can i filter a Pandas DataFrame which looks like this: Head Cat1 Cat2 Cat3 "A" 0 0 1 "B" 1 0 1 So that it returns for every row the Category-Column-Names if ... More on stackoverflow.com
🌐 stackoverflow.com
Best way to get names of all numeric columns in Pandas DataFrame?
cols2 is the answer I want (includes boolean as numeric) This has to be a bug in Pandas - the typesystem doesn't consider booleans to be a numeric type, so is_numeric_dtype shouldn't return True for a column of the boolean type. More on reddit.com
🌐 r/learnpython
5
2
November 17, 2021
Extract pandas dataframe column of tuples into separate columns
Could it be that readydata.index is the wrong size? Here is an example that uses locations.index: >>> locations = pd.DataFrame({'foo' : ['a', 'b', 'c'], 'point': [(1, 2, 3), (2, 3, 4), (3, 4, 5)]}) >>> locations foo point 0 a (1, 2, 3) 1 b (2, 3, 4) 2 c (3, 4, 5) >>> locations[['latitude', 'longitude', 'altitude']] = pd.DataFrame(locations['point'].to_list(), index=locations.index) >>> locations foo point latitude longitude altitude 0 a (1, 2, 3) 1 2 3 1 b (2, 3, 4) 2 3 4 2 c (3, 4, 5) 3 4 5 >>> More on reddit.com
🌐 r/learnpython
6
1
March 18, 2021
Panda - filter multiple columns by multiple values
You can use .isin(): RawData["Column3"].isin(["AAA", "BBB"]) More on reddit.com
🌐 r/learnpython
7
1
June 21, 2024
🌐
Pandas
pandas.pydata.org › docs › getting_started › intro_tutorials › 03_subset_data.html
How do I select a subset of a DataFrame? — pandas 3.0.6 documentation
To select a single column, use square brackets [] with the column name of the column of interest. For more explanation, see Brackets in Python and pandas. Each column in a DataFrame is a Series. As a single column is selected, the returned object is a pandas Series.
🌐
Saturn Cloud
saturncloud.io › blog › how-to-filter-pandas-dataframe-with-specific-column-names-in-python
How to Filter Pandas DataFrame with Specific Column Names in Python | Saturn Cloud Blog
May 1, 2026 - For example, you may want to filter a DataFrame to only include specific columns that are relevant to your analysis. One of the most straightforward methods to filter a Pandas DataFrame is by using square brackets to select columns of interest.
🌐
Medium
medium.com › @heyamit10 › how-to-filter-columns-based-on-conditions-5f4c41dac45b
How to Filter Columns Based on Conditions? | by Hey Amit | Medium
March 6, 2025 - ... “What if you need to grab columns that follow a pattern — maybe all columns that start with ‘S’ or contain a certain word?” · pandas’ .filter() lets you do exactly that. It works based on column names, making it useful when ...
🌐
GeeksforGeeks
geeksforgeeks.org › pandas › ways-to-filter-pandas-dataframe-by-column-values
Filter Pandas Dataframe by Column Value - GeeksforGeeks
July 15, 2025 - Filtering a Pandas DataFrame by column values is a common and essential task in data analysis. It allows to extract specific rows based on conditions applied to one or more columns, making it easier to work with relevant subsets of data.
🌐
Note.nkmk.me
note.nkmk.me › home › python › pandas
pandas: Filter rows/columns by labels with filter() | note.nkmk.me
January 24, 2024 - In pandas, use the filter() method to select rows or columns in the DataFrame based on their labels (names). This method is provided for both DataFrame and Series. pandas.DataFrame.filter — pandas 2. ...
Find elsewhere
🌐
Spark By {Examples}
sparkbyexamples.com › home › pandas › pandas filter by column value
Pandas Filter by Column Value - Spark By {Examples}
June 6, 2025 - Pandas support several ways to filter by column value, DataFrame.query() function is the most used to filter rows based on a specified expression,
🌐
Vultr Docs
docs.vultr.com › python › third-party › pandas › DataFrame › filter
Python Pandas DataFrame filter() - Filter Data Rows | Vultr Docs
December 25, 2024 - In this article, you will learn how to adeptly use the filter() function to filter rows in various scenarios with a Pandas DataFrame. Explore examples that demonstrate filtering data based on column names, based on conditions, dynamic filtration ...
🌐
ListenData
listendata.com › home › pandas
Python : 10 Ways to Filter Pandas DataFrame
age_threshold = 25 gender_value = 'Male' filtered_df = df.query('age > @age_threshold and gender == @gender_value') ... Make sure pandas package is already installed before submitting the following code. You can check it by running !pip show pandas statement in Ipython console.
🌐
Built In
builtin.com › data-science › pandas-filter
How to Filter Pandas DataFrames | Built In
Filtering in Pandas means to subset (or display) certain rows and columns in a Pandas DataFrame based on specified conditions. The dataframe.filter() function is one method of filtering a DataFrame in Pandas. Lines, or rows, in a Pandas DataFrame can be filtered by using one of the following methods: Filter by logical operators: df.values, df.name, etc.
🌐
Towards Data Science
towardsdatascience.com › home › latest › data filtering in pandas
Data filtering in Pandas | Towards Data Science
March 5, 2025 - In addition, Pandas also allows you to obtain a subset of data based on column types and to filter rows with boolean indexing. In this article, we will cover the most common operations for selecting a subset of data from a Pandas data frame: (1) selecting a single column by label, (2) selecting multiple columns by label, (3) selecting columns by data type, (4) selecting a single row by label, (5) selecting multiple rows by label, (6) selecting a single row by position, (7) selecting multiple rows by position, (8) selecting rows and columns simultaneously, (9) selecting a scalar value, and (10) selecting rows using Boolean selection.
🌐
Analytics Vidhya
analyticsvidhya.com › home › ways to filter pandas dataframe by column values
Ways to Filter Pandas DataFrame by Column Values
May 1, 2025 - Q3. How to filter by column value equals in Pandas? filtered_df = df[df[‘column_name’] == ‘value’]
🌐
YoungWonks
youngwonks.com › blog › top-10-ways-to-filter-pandas-dataframe
What is pandas and a pandas dataframe? What are the top 10 ways to filter pandas dataframe? Read our blog to learn more...
June 17, 2022 - It allows us to create subsets from the original dataset by forming smaller dataframes. This makes it easier to study, plot and analyze sections of the data. Therefore, it is important to know these commands in order to use them effectively. In this python tutorial, we are going to learn the top 10 ways to filter pandas dataframe. Making use of specific column names from the dataset, we can choose multiple columns from a pandas dataframe.
🌐
Stack Abuse
stackabuse.com › bytes › how-to-select-columns-in-pandas-based-on-a-string-prefix
How to Select Columns in Pandas Based on a String Prefix
August 16, 2023 - The filter() function allows us to select columns based on their labels. We can use the like parameter to specify a string pattern that matches the column names. However, if we want to select columns based on a string prefix, we can use the regex parameter. ... import pandas as pd # Create ...