Series.str.contains has a case parameter that is True by default. Set it to False to do a case insensitive match.

df2 = df1['company_name'].str.contains("apple", na=False, case=False)
Answer from Bill the Lizard on Stack Overflow
🌐
DataScientYst
datascientyst.com › pandas-contains-using-case-insensitive-search
Pandas: Contains Using Case Insensitive Search
May 16, 2025 - To perform case-insensitive string matching in Pandas, you can use the .str accessor along with regular expressions and the case=False parameter ... import pandas as pd df = pd.DataFrame({ 'name': ['maximum', 'Maxxy', 'MAXa', 'Mini', 'MInimum', ...
Discussions

python - Using Pandas str.contains using Case insensitive - Stack Overflow
My Dataframe: Req Col1 1 Apple is a fruit 2 Sam is having an apple 3 Orange is orange I am trying to create a new df having data related to apple only. My code: Apple=df1[df1.col1.str.contai... More on stackoverflow.com
🌐 stackoverflow.com
python - Filtering pandas dataframe rows by contains str - Stack Overflow
I have a python pandas dataframe df with a lot of rows. From those rows, I want to slice out and only use the rows that contain the word 'ball' in the 'body' column. To do that, I can do: ... The issue is, I want it to be case insensitive, meaning that if the word Ball or bAll showed up, I'll want those as well. One way to do case insensitive search is to turn the string ... More on stackoverflow.com
🌐 stackoverflow.com
How do I remove the case sensitivity while doing query
I have below Dataframe as df: Subject_Name Marks Science 40 Maths 45 English 38 Now when i do query as below: d2=df.query(‘Subject_Name == Science’)[‘Marks’] … More on discuss.python.org
🌐 discuss.python.org
2
0
May 12, 2022
regex - pandas python: access row by case insensitive label - Stack Overflow
I have a df and I would like to access a row by label, but I would like the casing of the label to be ignored. my df looks like this: Name exp1 Name Base 2074 Raw 2014 My failed attemp... More on stackoverflow.com
🌐 stackoverflow.com
🌐
Pandas
pandas.pydata.org › docs › reference › api › pandas.Series.str.contains.html
pandas.Series.str.contains — pandas 3.0.6 documentation
>>> s1.str.contains("house|dog", regex=True) 0 False 1 True 2 True 3 False 4 False dtype: bool · Ignoring case sensitivity using flags with regex.
🌐
Programiz
programiz.com › python-programming › pandas › methods › str-contains
Pandas str.contains() (With Examples)
Case-sensitive search: 0 False ... the exact case specified (lowercase a). data.str.contains('a', case=False) - ignores the case of a, thus matching both a and A in any element of the data Series. import pandas as pd # create a Series with missing values data = pd.Series(['apple', ...
🌐
Plus2Net
plus2net.com › python › pandas-str-contains.php
str.contains to search string or pattern matching in columns series using Pandas
str1 = df["id"] == 5 # id column value str2 = df.name.str.contains("Al", case=False) # name column value matching Al str3 = df["mark"] < 50 # mark column value less than 50 df2 = df[str1 | str2 | str3] # combine all conditions using | operator We can use AND matching so output must match to all conditions.
🌐
Like Geeks
likegeeks.com › home › python › pandas › ignore case sensitivity in pandas query method
Ignore Case Sensitivity in Pandas query Method
December 5, 2023 - ... To perform a case-insensitive search using the query method in Pandas, one approach is to use the str.lower() or str.upper() functions to convert all strings to a common case—either all lower case or all upper case.
Find elsewhere
🌐
Medium
medium.com › @whyamit101 › understanding-pandas-series-str-contains-7c9a3b3bd545
Understanding pandas.Series.str.contains()
February 26, 2025 - By default, str.contains() is case-sensitive. Setting case=False tells Pandas, “I don’t care about the case—just find the match.”
🌐
Python.org
discuss.python.org › python help
How do I remove the case sensitivity while doing query - Python Help - Discussions on Python.org
May 12, 2022 - I have below Dataframe as df: Subject_Name Marks Science 40 Maths 45 English 38 Now when i do query as below: d2=df.query(‘Subject_Name == Science’)[‘Marks’] …
🌐
Pandas
pandas.pydata.org › pandas-docs › stable › reference › api › pandas.Series.str.contains.html
pandas.Series.str.contains — pandas 3.0.5 documentation
>>> s1.str.contains("house|dog", regex=True) 0 False 1 True 2 True 3 False 4 False dtype: bool · Ignoring case sensitivity using flags with regex.
🌐
YouTube
youtube.com › watch
How to Use pandas str.contains for Case-Insensitive Filtering in DataFrames - YouTube
Learn how to filter a pandas DataFrame by using `str.contains` in a case-insensitive manner without changing the original column content.---This video is bas...
Published: May 27, 2025
Views: 1
🌐
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 - Use a flag to handle case-insensitive matching in regex. python Copy · mask = data.str.contains('A|B', regex=True, flags=re.IGNORECASE) print(mask) Explain Code · By introducing flags=re.IGNORECASE from the re library, you enhance the regular ...
🌐
GeeksforGeeks
geeksforgeeks.org › python-pandas-series-str-contains
Pandas Series.str.contains() - Python - GeeksforGeeks
June 12, 2025 - import pandas as pd import re sr = pd.Series(['apple', 'Banana', 'Mango', 'berry', 'GRAPE']) sr.index = ['Fruit 1', 'Fruit 2', 'Fruit 3', 'Fruit 4', 'Fruit 5'] res = sr.str.contains('grape', flags=re.IGNORECASE) print(res) Output : Case-Insensitive Match Using Flags ·
🌐
Runebook.dev
runebook.dev › en › docs › pandas › reference › api › pandas.series.str.contains
Pandas str.contains() Explained: A Friendly Guide to Common Gotchas
# The correct way to handle case-insensitivity result_correct = s.str.contains('apple', case=False) print(result_correct) # Output: # 0 True # 1 True # 2 False # dtype: bool
🌐
Reddit
reddit.com › r/learnpython › case insensitive using startswith
r/learnpython on Reddit: Case insensitive using startswith
May 13, 2020 -

I'm trying to do a quick database search in python using pandas.

data = pd.read_excel(open('Stockroom_Inventory_May_4_2020.xlsx', 'rb'),sheet_name='Chemical')

#This works fine for case insensitive search

data.loc[data['Item Name *'].str.contains('Ferro', case = False)][['Item Name *','Location','Sub-location','Location Details']]

#Can't use case = False with startswith

data.loc[data['Item Name *'].str.startswith('Ferro')][['Item Name *','Location','Sub-location','Location Details']]

Is there a way to get around this, even making everything from the excel file lowercase would be fine.

Thanks for your help

🌐
Pandas
pandas.pydata.org › pandas-docs › version › 0.23.0 › generated › pandas.Series.str.contains.html
pandas.Series.str.contains — pandas 0.23.0 documentation
>>> s1.str.contains('house|parrot', regex=True) 0 False 1 False 2 True 3 False 4 NaN dtype: object · Ignoring case sensitivity using flags with regex.