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.
๐ŸŒ
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.
๐ŸŒ
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)
๐ŸŒ
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!
๐ŸŒ
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.
๐ŸŒ
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
๐ŸŒ
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.
๐ŸŒ
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.