in of a Series checks whether the value is in the index:

In [11]: s = pd.Series(list('abc'))

In [12]: s
Out[12]: 
0    a
1    b
2    c
dtype: object

In [13]: 1 in s
Out[13]: True

In [14]: 'a' in s
Out[14]: False

One option is to see if it's in unique values:

In [21]: s.unique()
Out[21]: array(['a', 'b', 'c'], dtype=object)

In [22]: 'a' in s.unique()
Out[22]: True

or a python set:

In [23]: set(s)
Out[23]: {'a', 'b', 'c'}

In [24]: 'a' in set(s)
Out[24]: True

As pointed out by @DSM, it may be more efficient (especially if you're just doing this for one value) to just use in directly on the values:

In [31]: s.values
Out[31]: array(['a', 'b', 'c'], dtype=object)

In [32]: 'a' in s.values
Out[32]: True
Answer from Andy Hayden on Stack Overflow
๐ŸŒ
Statology
statology.org โ€บ home โ€บ pandas: how to check if value exists in column
Pandas: How to Check if Value Exists in Column
August 22, 2022 - This tutorial explains how to check if a particular value is in a column in pandas, including several examples.
Discussions

How to Check if Any Value in a List Is in either of Two Columns With Pandas
df[df[['work_email', 'personal_email']].isin(FilterThese).any(axis=1)] More on reddit.com
๐ŸŒ r/learnpython
3
6
December 12, 2022
python - Check if certain value is contained in a dataframe column in pandas - Stack Overflow
And .isin(vals) is the other way around, it checks whether the DataFrame/Series values are in the vals. Here vals must be set or list-like. So this is not the natural way to go for the question. ... Sign up to request clarification or add additional context in comments. ... I think you need str.contains, if you need rows where values of column ... More on stackoverflow.com
๐ŸŒ stackoverflow.com
How do i check if a dataframe column contains lists?
I'm not sure if pandas offers much help here apart from checking every value yourself: >>> df = pd.DataFrame({"A": [1, 2, 1], "B": [[4], "5", [4]]}) >>> df.map(lambda x: isinstance(x, list)) A B 0 False True 1 False False 2 False True Using tuples is the usual approach if the list type is not important to you: >>> df.map(lambda x: tuple(x) if isinstance(x, list) else x).drop_duplicates() A B 0 1 (4,) 1 2 5 (If the lists are nested, you'll need to change them at each level.) More on reddit.com
๐ŸŒ r/learnpython
6
1
June 18, 2024
How to test if all values in pandas dataframe column are equal?
Don't think there's a built-in functionality to quickly do that, but it can be done in two steps: In [19]: df Out[19]: A B 0 h h 1 h h 2 h i Count the number of uniques in each column: In [20]: uniques = df.apply(lambda x: x.nunique()) In [21]: uniques Out[21]: A 1 B 2 dtype: int64 Use boolean indexing on uniques to filter out rows where the number of uniques is not equal to one. Use the result's index to drop the columns in the original dataframe. In [22]: df = df.drop(uniques[uniques==1].index, axis=1) In [23]: df Out[23]: B 0 h 1 h 2 i More on reddit.com
๐ŸŒ r/learnpython
4
1
March 9, 2017
๐ŸŒ
Reddit
reddit.com โ€บ r/learnpython โ€บ how to check if any value in a list is in either of two columns with pandas
r/learnpython on Reddit: How to Check if Any Value in a List Is in either of Two Columns With Pandas
December 12, 2022 -

I am loading a csv as a pandas dataframe.

The headers of the csv are: fname,lname,linkedin_url,work_email,personal_email,cell_phone,company_name,job_title,company_website,industry,location,gender,birth_day

I have a list of emails that I want to filter the dataframe with and keep the records that are in the list. I figured out how to do it based on one column using this:

datafilters = df['work_email'].isin(FilterThese)

How do I adjust the above so it checks if the values in the list "FilterThese" exist in either 'work_email' or 'personal_email'?

Thank you!

๐ŸŒ
Pandas
pandas.pydata.org โ€บ docs โ€บ reference โ€บ api โ€บ pandas.DataFrame.isin.html
pandas.DataFrame.isin โ€” pandas 3.0.1 documentation
To check if values is not in the DataFrame, use the ~ operator: >>> ~df.isin([0, 2]) num_legs num_wings falcon False False dog True False ยท When values is a dict, we can pass values to check for each column separately:
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ check-if-a-value-exists-in-a-dataframe-using-in-not-in-operator-in-python-pandas
Check if a value exists in a DataFrame using in & not in operator in Python-Pandas - GeeksforGeeks
July 15, 2025 - Method 1 : Use in operator to check if an element exists in dataframe. Python3 ยท # import pandas library import pandas as pd # dictionary with list object in values details = { 'Name' : ['Ankit', 'Aishwarya', 'Shaurya', 'Shivangi', 'Priya', 'Swapnil'], 'Age' : [23, 21, 22, 21, 24, 25], 'University' : ['BHU', 'JNU', 'DU', 'BHU', 'Geu', 'Geu'], } # creating a Dataframe object df = pd.DataFrame(details, columns = ['Name', 'Age', 'University'], index = ['a', 'b', 'c', 'd', 'e', 'f']) print("Dataframe: \n\n", df) # check 'Ankit' exist in dataframe or not if 'Ankit' in df.values : print("\nThis value exists in Dataframe") else : print("\nThis value does not exists in Dataframe") Output : Method 2: Use not in operator to check if an element doesnโ€™t exists in dataframe.
๐ŸŒ
Saturn Cloud
saturncloud.io โ€บ blog โ€บ how-to-check-if-one-value-exists-in-any-rows-of-any-columns-in-pandas
How to Check if One Value Exists in Any Rows of Any Columns in Pandas | Saturn Cloud Blog
December 19, 2023 - In this blog post, we discussed different methods to check if one value exists in any rows of any columns in pandas. We explored the any() method, isin() method, and applymap() method to accomplish this task. These methods are easy to use and ...
Find elsewhere
๐ŸŒ
Saturn Cloud
saturncloud.io โ€บ blog โ€บ how-to-check-if-pandas-column-has-value-from-list-of-strings
How to Check if Pandas Column Has Value from List of Strings | Saturn Cloud Blog
November 3, 2023 - In this article, weโ€™ve learned two ways to check if a Pandas column has a value from a list of strings: using the .isin() method and using a list comprehension.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ pandas โ€บ how-to-check-if-pandas-column-has-value-from-list-of-string
How to Check if a Pandas Column Has a Value from a List of Strings? - GeeksforGeeks
June 12, 2025 - For example, if we have a list like ['java', 'c'] and want to find all rows in the subjects column containing these values, the output will only include the rows where the subject is 'java' or 'c'. The isin() function checks whether each value ...
๐ŸŒ
Skytowner
skytowner.com โ€บ explore โ€บ checking_if_a_dataframe_column_contains_some_values_in_pandas
Checking if a DataFrame column contains some values in Pandas
We first fetch column A as a Series using df["A"], and then we use isin(~) to obtain a boolean mask where True represents the presence of a value in the given list: df["A"].isin([3,8]) # returns a Series of booleans ... Here, we get True for row 1 since it holds the value 3. Finally, we use the Series' any() method that returns True if there is at least one True in the Series: ... Checks if certain values are present in the DataFrame.
๐ŸŒ
Quora
quora.com โ€บ If-I-want-to-check-if-a-value-exists-in-a-Panda-dataframe-what-Python-code-can-I-write
If I want to check if a value exists in a Panda dataframe, what Python code can I write? - Quora
Answer (1 of 7): The ways :- 1.If you want to search single value in whole dataframe [code]yourValue = randomNumber for cols in df.columns: if (yourValue in df[cols]: print('Found in '+cols) #to print the column name if found [/code]for text value instead of number you can use astype(str) af...
๐ŸŒ
w3resource
w3resource.com โ€บ python-exercises โ€บ pandas โ€บ index โ€บ pandas-indexing-exercise-11.php
Pandas: Check if a value exists in single/multiple columns index dataframe - w3resource
September 6, 2025 - import pandas as pd df = pd.DataFrame({ 'school_code': ['s001','s002','s003','s001','s002','s004'], 'class': ['V', 'V', 'VI', 'VI', 'V', 'VI'], 'name': ['Alberto Franco','Gino Mcneill','Ryan Parkes', 'Eesha Hinton', 'Gino Mcneill', 'David Parkes'], 'date_of_birth': ['15/05/2002','17/05/2002','16/02/1999','25/09/1998','11/05/2002','15/09/1997'], 'weight': [35, 32, 33, 30, 31, 32]}, index = ['t1', 't2', 't3', 't4', 't5', 't6']) print("Original DataFrame with single index:") print(df) print("\nCheck a value is exist in single column index dataframe:") print('t1' in df.index) print('t11' in df.ind
๐ŸŒ
TutorialsPoint
tutorialspoint.com โ€บ article โ€บ checking-if-a-value-exists-in-a-dataframe-using-in-and-not-in-operators-in-python-pandas
Checking if a Value Exists in a DataFrame using \'in\' and \'not in\' Operators in Python Pandas
September 1, 2023 - We aim to check if the value "Michael" does not exist in the 'Name' column. By utilizing the "not in" operator, we compare the value against the values in the "Name" column using the ".values" attribute. Consider the code shown below. import pandas as pd # Create a DataFrame df = pd.DataFrame({'Name': ['John', 'Alice', 'Bob', 'Emily'],'Age': [25, 30, 28, 35]}) # Check if a value does not exist in the 'Name' column value = 'Michael' if value not in df['Name'].values: print(f"{value} does not exist in the DataFrame.") else: print(f"{value} exists in the DataFrame.")
Top answer
1 of 3
66

You can simply use this:

'07311954' in df.date.values which returns True or False


Here is the further explanation:

In pandas, using in check directly with DataFrame and Series (e.g. val in df or val in series ) will check whether the val is contained in the Index.

BUT you can still use in check for their values too (instead of Index)! Just using val in df.col_name.values or val in series.values. In this way, you are actually checking the val with a Numpy array.

And .isin(vals) is the other way around, it checks whether the DataFrame/Series values are in the vals. Here vals must be set or list-like. So this is not the natural way to go for the question.

2 of 3
35

I think you need str.contains, if you need rows where values of column date contains string 07311954:

print df[df['date'].astype(str).str.contains('07311954')]

Or if type of date column is string:

print df[df['date'].str.contains('07311954')]

If you want check last 4 digits for string 1954 in column date:

print df[df['date'].astype(str).str[-4:].str.contains('1954')]

Sample:

print df['date']
0    8152007
1    9262007
2    7311954
3    2252011
4    2012011
5    2012011
6    2222011
7    2282011
Name: date, dtype: int64

print df['date'].astype(str).str[-4:].str.contains('1954')
0    False
1    False
2     True
3    False
4    False
5    False
6    False
7    False
Name: date, dtype: bool

print df[df['date'].astype(str).str[-4:].str.contains('1954')]
     cmte_id trans_typ entity_typ state  employer  occupation     date  \
2  C00119040       24K        CCM    MD       NaN         NaN  7311954   

   amount     fec_id    cand_id  
2    1000  C00140715  H2MD05155  
๐ŸŒ
TutorialsPoint
tutorialspoint.com โ€บ article โ€บ how-to-check-if-pandas-column-has-value-from-list-of-string
How to check if Pandas column has value from list of string?
August 9, 2023 - In this example, we will use the isin() function of the NumPy library to check if pandas column has value from list of strings.
๐ŸŒ
Statology
statology.org โ€บ home โ€บ pandas: formula for โ€œif value in column thenโ€
Pandas: Formula for "If Value in Column Then"
November 16, 2022 - You can use the following syntax in pandas to assign values to one column based on the values in another column: df['new'] = df['col'].map(lambda x: 'new1' if 'A' in x else 'new2' if 'B' in x else '')