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.
🌐
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)
🌐
Programiz
programiz.com › python-programming › pandas › methods › str-contains
Pandas str.contains() (With Examples)
The str.contains() method returns a Boolean Series showing whether each element in the Series contains the pattern or regex.
🌐
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:
🌐
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 …
🌐
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.
Find elsewhere
🌐
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.
🌐
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!
🌐
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.
🌐
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.
🌐
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
Pandas is the go-to library for data manipulation in Python, and string operations are a common part of data cleaning and analysis. One of the most useful string methods in pandas is str.contains(), which checks if a substring exists within a string column. But what if you need to match multiple ...
🌐
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.
🌐
Metaschool
metaschool.so › home › software development › master string searches in python 2025
Master String Searches in Python 2025
February 7, 2025 - However, you can achieve this by iterating through a list of substrings and checking each one individually. For example, you can use a loop with the in keyword to check if any of the substrings are present in the main string.
🌐
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.
🌐
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
🌐
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.
🌐
Note.nkmk.me
note.nkmk.me › home › python
Search for a String in Python (Check If a Substring Is Included/Get a Substring Position) | note.nkmk.me
May 7, 2023 - Read, write, and create files in Python (with and open()) Use the in operator to check if a string contains a given substring. The in operator is case-sensitive, and the same applies to the string methods described below.