You can use the isin method:

In [1]: df = pd.DataFrame({'A': [5,6,3,4], 'B': [1,2,3,5]})

In [2]: df
Out[2]:
   A  B
0  5  1
1  6  2
2  3  3
3  4  5

In [3]: df[df['A'].isin([3, 6])]
Out[3]:
   A  B
1  6  2
2  3  3

And to get the opposite use ~:

In [4]: df[~df['A'].isin([3, 6])]
Out[4]:
   A  B
0  5  1
3  4  5
Answer from Wouter Overmeire on Stack Overflow
🌐
Statology
statology.org › home › pandas: how to filter rows based on values in a list
Pandas: How to Filter Rows Based on Values in a List
January 5, 2023 - This tutorial explains how to filter a pandas DataFrame for rows where a particular column contains a value in a list.
Discussions

How can I get a List of unique values in a column?
u/Mugiwara_JTres3 - Your post was submitted successfully. Once your problem is solved, reply to the answer(s) saying Solution Verified to close the thread. Follow the submission rules -- particularly 1 and 2. To fix the body, click edit. To fix your title, delete and re-post. Include your Excel version and all other relevant information Failing to follow these steps may result in your post being removed without warning. I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns. More on reddit.com
🌐 r/excel
27
24
August 29, 2022
How can I use the filter in a pandas data frame using a dictionary containing some values?
Firstly, this is a pandas question that is unrelated to django…? Also your variable dict is not a dictionary but a simple list. You can load your CSV into a pandas dataframe and then filter it with filtered_df = df[df.B.isin(dict)] More on reddit.com
🌐 r/django
4
2
August 19, 2021
How do I filter a dataframe based on if a certain string is contained within a list stored in a column?
figured it out - it's the first code snippet but you need "regex=False" set in the contains() method (there are underscore characters in my strings which was probably messing something up) More on reddit.com
🌐 r/learnpython
1
5
July 17, 2025
using pandas column value to filter columns.
Think about which dataframe you're referencing in your filtering and start with how you would do this operation if you were just passing a list of static values as columns to be selected into the new dataframe. Maybe you don't need to do this many operations to access the values you need. Also consider whether .isin is the best method to use here given that it returns booleans. Maybe .values is more appropriate to reference the items in the "new" series. More on reddit.com
🌐 r/learnpython
11
1
December 12, 2022
🌐
GeeksforGeeks
geeksforgeeks.org › pandas › select-rows-from-list-of-values-in-pandas-dataframe
Select Rows From List of Values in Pandas DataFrame - GeeksforGeeks
July 23, 2025 - You can filter rows by using multiple isin() methods in combination with the AND (&) operator. This is especially helpful when you want to check multiple columns against different lists of values.
🌐
Data Science Parichay
datascienceparichay.com › home › blog › filter dataframe rows on a list of values
Filter DataFrame rows on a list of values - Data Science Parichay
December 27, 2020 - To filter rows of a pandas dataframe based on a list of values for a column you can use the isin() membership function.
🌐
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,
🌐
Saturn Cloud
saturncloud.io › blog › how-to-select-rows-from-a-dataframe-based-on-list-values-in-a-column-in-pandas
How to Select Rows from a DataFrame Based on List Values in a Column in Pandas | Saturn Cloud Blog
May 1, 2026 - To select rows from a DataFrame based on a list of values in a column, we can use the isin() method of pandas. This method returns a Boolean mask that indicates whether each element of a DataFrame column is contained in a list of values.
Find elsewhere
🌐
Analytics Vidhya
analyticsvidhya.com › home › ways to filter pandas dataframe by column values
Ways to Filter Pandas DataFrame by Column Values
May 1, 2025 - Q2.How to filter a DataFrame based on a list of values? To filter a DataFrame based on a list of values in Pandas: Use .isin() on the column with your list to create a boolean mask.
🌐
Saturn Cloud
saturncloud.io › blog › how-to-filter-for-a-list-of-values-in-python-pandas-using-loc
How to Filter for a List of Values in Python Pandas Using Loc | Saturn Cloud Blog
May 1, 2026 - In this article, we explored how to filter for a list of values in a pandas dataframe using the loc function. We demonstrated how to use the isin method to filter based on a list of values in one column and how to combine multiple conditions ...
🌐
Educative
educative.io › answers › how-to-filter-pandas-dataframe-by-column-value
How to filter pandas DataFrame by column value
isin() method: We can filter rows of a DataFrame based on whether the values in a specified column are present in a given list or array. ... To learn how we can apply a filter on the column values, let's first create a data example.
🌐
CodeRivers
coderivers.org › blog › python-dataframe-filter-column-value-in-list
Python DataFrame: Filtering Column Values in a List - CodeRivers
February 22, 2026 - By indexing the DataFrame with this mask (df[df['City'].isin(cities_list)]), we get the filtered DataFrame that only contains rows where the City value is either New York or Sydney. Boolean indexing can also be used to achieve the same result. We can create a boolean condition by comparing each value in the column with the values in the list element-by-element. import pandas as pd data = { 'Name': ['Alice', 'Bob', 'Charlie', 'David', 'Eve'], 'Age': [25, 30, 35, 40, 45], 'City': ['New York', 'London', 'Paris', 'New York', 'Sydney'] } df = pd.DataFrame(data) cities_list = ['New York', 'Sydney'] mask = False for city in cities_list: mask = mask | (df['City'] == city) filtered_df = df[mask] print(filtered_df)
🌐
GeeksforGeeks
geeksforgeeks.org › pandas › ways-to-filter-pandas-dataframe-by-column-values
Filter Pandas Dataframe by Column Value - GeeksforGeeks
July 15, 2025 - This code filters the DataFrame to include only rows where the "Age" column has values of either 25 or 45. The .query() method allows you to filter a DataFrame using SQL-like syntax. This can be particularly useful when dealing with complex conditions. ... import pandas as pd data = {'Name': ['Alice', 'Bob', 'Charlie'], 'Age': [25, 32,45], 'Score': [85, 90, 78]} df = pd.DataFrame(data) # Filter using query method where Age > 30 and Score < 90 filtered_df = df.query('Age > 30 and Score < 90') print(filtered_df)
🌐
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
🌐
Arab Psychology
scales.arabpsychology.com › home › how do i filter rows of a pandas dataframe by column value?
How Do I Filter Rows Of A Pandas DataFrame By Column Value?
November 22, 2025 - Instead of writing cumbersome logical OR statements, you supply a list or series of target values, and pandas handles the comparison across the entire selected column. This results in cleaner code, improved readability, and significantly faster execution times when dealing with large-scale DataFrame operations. This guide will explore the mechanics of using isin() to filter rows in a DataFrame.
🌐
Medium
deallen7.medium.com › using-pandas-loc-and-isin-to-filter-for-a-list-of-values-in-python-a1c862054058
Using Pandas’ .loc and .isin() to Filter for a List of Values in Python | by David Allen | Medium
July 26, 2022 - Image by 95C from Pixabay · Member-only story · Data Science · Data · Python · Pandas · David Allen · 2 min read · ·Jul 19, 2021 · -- 1 · Listen · Share · I use .loc on a daily basis. It’s like using the filter function on a spreadsheet. It’s an effortless way to filter down a Pandas Dataframe into a smaller chunk of data. It typically works like this: new_df = df.loc[df.column == 'value'] Sometimes, you’ll want to filter by a couple of conditions.
🌐
Statology
statology.org › home › how to filter a pandas dataframe by column values
How to Filter a Pandas DataFrame by Column Values
March 11, 2021 - The following code shows how to filter the rows of the DataFrame based on values in a list · #define list of values value_list = [12, 19, 25] #return rows where points is in the list of values df.query('points in @value_list') team points assists rebounds 0 A 25 5 11 1 A 12 7 8 4 C 19 12 6 #return rows where points is not in the list of values df.query('points not in @value_list') team points assists rebounds 2 B 15 7 10 3 B 14 9 6 · How to Replace Values in Pandas How to Drop Rows with NaN Values in Pandas How to Drop Duplicate Rows in Pandas
🌐
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
Fare Cabin Embarked 0 1 0 3 ... 7.2500 NaN S 1 2 1 1 ... 71.2833 C85 C 2 3 1 3 ... 7.9250 NaN S 3 4 1 1 ... 53.1000 C123 S 4 5 0 3 ... 8.0500 NaN S [5 rows x 12 columns] The notna() conditional function returns a True for each row the values are not a Null value. As such, this can be combined with the selection brackets [] to filter the data table.
🌐
Built In
builtin.com › data-science › pandas-filter
How to Filter Pandas DataFrames | Built In
We’ve now selected the rows in which the value in the “val” column is greater than 0.5. The logical operators function also works on strings. f[df.name > 'Jane'] name ctg val val2 ------------------------------------------- 1 John A 0.67 1 3 Mike B 0.91 5 · Only the names that come after “Jane” in alphabetical order are selected. Pandas allows for combining multiple logical operators.
🌐
Towards Data Science
towardsdatascience.com › home › latest › data filtering in pandas
Data filtering in Pandas | Towards Data Science
March 5, 2025 - Then, the sequence of booleans is placed inside square brackets [], returning the rows associated with a True value. ... The most common way to filter a data frame according to the values of a single column is by using a comparison operator.