They should be one regular expression, and should be in one string:

"nt|nv"  # rather than "nt" | " nv"
f_recs[f_recs['Behavior'].str.contains("nt|nv", na=False)]

Python doesn't let you use the or (|) operator on strings:

In [1]: "nt" | "nv"
TypeError: unsupported operand type(s) for |: 'str' and 'str'
Answer from Andy Hayden on Stack Overflow
🌐
w3resource
w3resource.com › pandas › series › series-str-contains.php
Pandas Series: str.contains() function - w3resource
May 18, 2026 - import numpy as np import pandas as pd s1 = pd.Series(['Tiger', 'fox', 'house and men', '20', np.NaN]) ind = pd.Index(['Tiger', 'fox', 'house and men', '20.0', np.NaN]) import re s1.str.contains('\d', regex=True) ... Ensure pat is a not a literal pattern when regex is set to True. Note in the following example one might expect only s2[1] and s2[3] to return True.
Discussions

Find column names that contain multiple strings at the same time
df[df["account"].str.contains(r'(?=.*creating)(?=.*damage)', regex=True)] or df[df["account"].str.contains('creating') & df["account"].str.contains('damage')] More on reddit.com
🌐 r/learnpython
3
1
January 10, 2022
How to check for multiple substrings in a vector
SOLVED using the stringr package. library(stringr) str_detect(addresses, "Netherlands|Sweden|Ukraine") More on reddit.com
🌐 r/Rlanguage
4
1
November 3, 2021
How to fix the "multiple repeat at position 2" error

Ah, thanks!

More on reddit.com
🌐 r/learnpython
2
2
July 6, 2020
How to speed up multiple str.contains searches for millions of rows?
668k members in the learnpython community. Subreddit for posting questions and asking for general advice about your python code. More on reddit.com
🌐 r/learnpython
February 1, 2020
🌐
Programiz
programiz.com › python-programming › pandas › methods › str-contains
Pandas str.contains() (With Examples)
The str.contains() method is used to test if a pattern or regex is contained within a string of a Series. The str.contains() method in Pandas is used to test if a pattern or regex is contained within a string of a Series.
🌐
Statology
statology.org › home › pandas: check if string contains multiple substrings
Pandas: Check if String Contains Multiple Substrings
October 10, 2022 - You can use the following methods to check if a string in a pandas DataFrame contains multiple substrings: Method 1: Check if String Contains One of Several Substrings · df['string_column'].str.contains('|'.join(['string1', 'string2'])) Method 2: Check if String Contains Several Substrings · df['string_column'].str.contains(r'^(?=.*string1)(?=.*string2)') The following examples show how to use each method in practice with the following pandas DataFrame:
🌐
GeeksforGeeks
geeksforgeeks.org › pandas › python-pandas-series-str-contains
Pandas Series.str.contains() - Python - GeeksforGeeks
January 13, 2026 - Example 1: This example uses a regex pattern to find names where "i" is followed by a lowercase letter. ... import pandas as pd s = pd.Series(['Mike', 'Nick', 'Kim', 'John']) r = s.str.contains('i[a-z]', regex=True) print(r)
🌐
Real Python
realpython.com › python-string-contains-substring
How to Check if a Python String Contains a Substring – Real Python
December 1, 2024 - Python counted how often the substring appears in the string and returned the answer. The text contains the substring four times. But what do these substrings look like? You can inspect all the substrings by splitting your text at default word borders and printing the words to your terminal using a for loop: ... >>> for word in file_content.split(): ... if "secret" in word: ... print(word) ... secret secret. secret, secretly · In this example, you use .split() to separate the text at whitespaces into strings, which Python packs into a list.
Find elsewhere
🌐
Quora
quora.com › How-do-I-check-if-a-string-contains-multiple-values-in-Python
How to check if a string contains multiple values in Python - Quora
Quora is a place to gain and share knowledge. It's a platform to ask questions and connect with people who contribute unique insights and quality answers.
🌐
DigitalOcean
digitalocean.com › community › tutorials › python-string-contains
Python String contains | DigitalOcean
June 18, 2024 - Learn how to check if one Python string contains another using the contains () method. This case-sensitive instance method returns True or False based on …
🌐
Net Informations
net-informations.com › python › basics › multiple.htm
Check if multiple strings exist in another string : Python
If your list is too long, it is better to use Python Regular Expression . import re myList = ['six','ten','One'] str = "one two three four five" if any(re.findall(''.join(myList), str, re.IGNORECASE)): print("Found a match") else: print("Not Found a match") Above example return "Found a match" because "one" is exist in the list.
🌐
Pandas
pandas.pydata.org › docs › reference › api › pandas.Series.str.contains.html
pandas.Series.str.contains — pandas 3.0.4 documentation
>>> s1.str.contains("\\d", regex=True) 0 False 1 False 2 False 3 True 4 False dtype: bool · Ensure pat is a not a literal pattern when regex is set to True. Note in the following example one might expect only s2[1] and s2[3] to return True.
🌐
Analytics Vidhya
analyticsvidhya.com › home › learn how to check if a string contains a substring in python
Learn How to Check If a String Contains a Substring in Python - Analytics Vidhya
January 10, 2024 - To check if a string contains multiple ... ... string = "Hello, World!" substrings = ["Hello", "Python"] if all(substring in string for substring in substrings): print("All substrings found!") else: print("One or more substrings not found.")...
🌐
Medium
medium.com › @amit25173 › understanding-pandas-str-contains-ba3e6a7d30b3
Understanding pandas str.contains() | by Amit Yadav | Medium
March 6, 2025 - Only 'apple' and 'banana' contain 'a', so they return True. This is super handy when you’re dealing with mixed data types in a column. And there you have it — some of the most common questions about str.contains(), answered with code!
🌐
pythontutorials
pythontutorials.net › blog › how-to-use-str-contains-with-multiple-expressions-in-pandas-dataframes
How to Use str.contains() with Multiple Expressions in Pandas DataFrames (Single Line Method) — pythontutorials.net
Whether you’re filtering customer reviews for negative keywords, analyzing text data for specific themes, or cleaning messy strings, efficiently checking for multiple expressions is critical. In this blog, we’ll demystify how to use str.contains() with multiple expressions in a single line using regular expressions (regex), with clear examples and best practices.
🌐
Vultr Docs
docs.vultr.com › python › third-party › pandas › Series › str › contains
Python Pandas Series str contains() - Check Substring Presence | Vultr Docs
December 5, 2024 - The code above creates a series of fruit names and then uses str.contains() to find all entries containing the letter 'a'. The result is a boolean series indicating which elements match the condition. Handle case sensitivity by adjusting the case parameter. Demonstrate how toggling this parameter affects string matching. ... This example considers both uppercase and lowercase letters by setting case to False.
🌐
DigitalOcean
digitalocean.com › community › tutorials › python-check-if-string-contains-another-string
How To Check If a String Contains Another String in Python | DigitalOcean
April 9, 2026 - Learn how to check if one string contains another in Python using in, find(), and regular expressions. Explore common pitfalls, and efficient practices.
🌐
Metaschool
metaschool.so › home › software development › master string searches in python 2025
Master String Searches in Python 2025
February 7, 2025 - A substring is a sequence of characters ... characters are adjacent and in the same order. For example, in the string "hello", "ell" and "lo" are substrings....
🌐
Spark By {Examples}
sparkbyexamples.com › home › pandas › pandas series.str.contains() with examples
Pandas Series.str.contains() With Examples - Spark By {Examples}
December 9, 2024 - Pandas Series.str.contains() method is used to check whether each string in a Series contains a specified substring or pattern. It returns a
🌐
IncludeHelp
includehelp.com › python › pandas-dataframe-str-contains-and-operation.aspx
Python - Pandas dataframe str.contains() AND operation
October 3, 2022 - # Importing pandas package import pandas as pd # Creating two dictionaries d = {'col':['A boy', 'A good boy', 'A vergy good boy', 'I am a very good boy']} # Creating DataFrame df = pd.DataFrame(d) # Display Original DataFrame print("Created DataFrame:\n",df,"\n") # Using contains and AND operation res = df[(df['col'].str.contains('good')) & (df['col'].str.contains('am'))] # Display result print("Result:\n",res)
🌐
Bacancy Technology
bacancytechnology.com › qanda › python › python-string-contains
How does Python string contains substring method?
For example, the following code checks if the string “hello” contains the substring “ell” using a regular expression: import re string = "hello" substring = "ell" pattern = r"ell" if re.search(pattern, string): print("The substring is found") else: print("The substring is not found") ... There are a few ways to check if a string contains a substring in Python.