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 - Python-Pandas Code: 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]) ind.str.contains('20', regex=False) Output: Index([False, False, False, True, nan], dtype='object') Example - Specifying case sensitivity using case: Python-Pandas Code: 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]) s1.str.contains('oX', case=True, regex=True) Output: 0 False 1 False 2 False 3 False 4 NaN dtype: object ·
🌐
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.
🌐
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 ...
Find elsewhere
🌐
Statology
statology.org › home › pandas: check if string contains multiple substrings
Pandas: Check if String Contains Multiple Substrings
October 10, 2022 - We can use the following syntax to check if each string in the team column contains either the substring “Good” or “East”:
🌐
GeeksforGeeks
geeksforgeeks.org › pandas › python-pandas-series-str-contains
Pandas Series.str.contains() - Python - GeeksforGeeks
January 13, 2026 - Example 3: This example shows how Series.str.contains() behaves when the Series contains missing values and how to handle them using the na parameter. ... import pandas as pd s = pd.Series(['Python', None, 'Pandas', 'NumPy']) r = s.str.contains('Py', na=False) print(r)
🌐
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.
🌐
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)
🌐
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.
🌐
Medium
medium.com › @amit25173 › understanding-pandas-str-contains-ba3e6a7d30b3
Understanding pandas str.contains() | by Amit Yadav | Medium
March 6, 2025 - So, if you need to find something inside the string — go with contains(). If you’re checking from the start—use match(). ... This might surprise you: You can search for multiple substrings using just one line of code, thanks to regular expressions (regex).
🌐
CodeFatherTech
codefather.tech › home › blog › how to check if a python string contains a substring
How to Check if a Python String Contains a Substring - Codefather
December 8, 2024 - It’s very common having to check if a string contains multiple substrings. Imagine you have a document and you want to confirm, given a list of words, which ones are part of the document. In this example we are using a short string but imagine the string being a document of any length. document = "The Python programming language was created by Guido van Rossum" words = ["Python", "Rossum", "substring"]
🌐
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.
🌐
DigitalOcean
digitalocean.com › community › tutorials › python-string-contains
Python String contains | DigitalOcean
June 18, 2024 - print(str.__contains__('ABC', 'A')) print(str.__contains__('ABC', 'D')) ... Let’s look at another example where we will ask the user to enter both the strings and check if the first string contains the second string or substring or not.
🌐
Note.nkmk.me
note.nkmk.me › home › python › pandas
pandas: Extract rows that contain specific strings from a DataFrame | note.nkmk.me
July 30, 2023 - By using str.contains(), you can generate a Series where elements that contain a given substring are True.