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
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
Case insensitive using startswith
maybe str.lower().str.startswith() would work? More on reddit.com
🌐 r/learnpython
6
1
May 13, 2020
Need help with case insensitive list comparison in Python
You could just make both names lower-case when doing the comparison/search More on reddit.com
🌐 r/learnprogramming
5
1
August 26, 2019
Case insensitive .contains() Sqlalchemy ?
func.lower() More on reddit.com
🌐 r/flask
7
8
September 20, 2021
🌐
EyeHunts
tutorial.eyehunts.com › home › python string contains case insensitive | example code
Python string contains case insensitive | Example code
April 25, 2022 - str1 = "Messi is the best SoCceR player" if "soccer" in str1.lower(): print("Contain soccer") if "Player" in str1: print("Contain football") ... Answer: Make the string lowercase or uppercase before matching it. ... Do comment if you have any doubts or suggestions on this Python string topic.
🌐
Mathspp
mathspp.com › blog › how-to-work-with-case-insensitive-strings
How to work with case-insensitive strings | mathspp
January 21, 2023 - To implement the class CaseInsensitiveSet, we will follow an approach that is very similar to the one employed above to implement a case-insensitive dictionary. We just need to be aware that an expression like value in set depends on the dunder method __contains__. We will inherit from the built-in set and we will override the methods that we are interested in. Then, we just need to use the string method str.casefold before deferring to the original methods that do value insertion/removal/membership testing.
🌐
Bobby Hadz
bobbyhadz.com › blog › python-check-if-string-is-in-list-case-insensitive
Check if List contains a String case-insensitive in Python | bobbyhadz
Both strings have to either be lowercase or uppercase to perform a case-insensitive comparison. If your list contains items that aren't strings, use the str() class to convert each item to a string before calling the lower() method.
🌐
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.
🌐
thisPointer
thispointer.com › home › python › python : check if a string contains a sub string & find it’s index | case insensitive
Python : Check if a String contains a sub string & find it's index | case insensitive - thisPointer
April 30, 2023 - As our main string doesn’t contains the sub-string ‘Hello’ therefore ‘not in’ operator returned True. Check if First Letter of String is Uppercase in Python ... Python : Find occurrence count & all indices of a sub-string in another string | including overlapping sub-strings · To check if a given string or a character exists in an another string or not in case insensitive manner i.e.
Find elsewhere
🌐
Programiz
programiz.com › python-programming › pandas › methods › str-contains
Pandas str.contains() (With Examples)
# case-sensitive search (default behavior) case_sensitive_result = data.str.contains('a') # case-insensitive search case_insensitive_result = data.str.contains('a', case=False) print("Case-sensitive search:\n", case_sensitive_result) print("\nCase-insensitive search:\n", case_insensitive_result)
🌐
iO Flood
ioflood.com › blog › python-string-contains
Python String Contains | Methods and Usage Examples
December 5, 2023 - In this example, we’re checking if the word ‘fun’ is in the sentence ‘Python is Fun!’ in a case-insensitive manner. By converting both the string and the substring to lowercase, we ensure that the check is not affected by the letter case.
🌐
Codecademy
codecademy.com › article › how-to-check-if-a-string-contains-a-substring-in-python
How to Check if a String Contains a Substring in Python | Codecademy
Next, let’s go through an example that uses the .contains() method to check for a substring in a string: ... In all the methods that we’ve discussed so far, we’ve kept matching cases for strings and substrings. But what happens if the cases don’t match? Let’s discuss that in the next section. Python’s case sensitivity can make substring searches challenging at times and result in mismatches. This is where case-insensitive checks come in.
🌐
Medium
medium.com › @whyamit101 › understanding-pandas-series-str-contains-7c9a3b3bd545
Understanding pandas.Series.str.contains()
February 26, 2025 - Both Alice and Charlie contain “li.” Simple, right? Case 2: Handling Case Sensitivity · Now, here’s a twist: What if the casing doesn’t match? For example, what if you’re looking for “ALICE” in uppercase, but your data has “Alice”? # Case-insensitive search using `case` parameter mask = df['Name'].str.contains('ALICE', case=False) print(df[mask]) Why add case=False?
🌐
GeeksforGeeks
geeksforgeeks.org › python › case-insensitive-string-comparison-in-python
Case-insensitive string comparison in Python - GeeksforGeeks
July 15, 2025 - Explanation: This code uses casefold() for accurate case-insensitive comparison, especially with international characters. It converts all strings, checks uniqueness using a set and prints "equal" if all are identical otherwise, "unequal". re.match() checks if a string matches a pattern from the start and with the re.IGNORECASE flag, it ignores case differences.
🌐
Metaschool
metaschool.so › home › software development › master string searches in python 2025
Master String Searches in Python 2025
February 7, 2025 - Yes, string containment checks in Python are case-sensitive by default. This means that the check will distinguish between uppercase and lowercase characters. For instance, checking if "hello" is in "Hello World" will return False because of ...
🌐
GoLinuxCloud
golinuxcloud.com › home › programming › python › check if string contains substring in python
Check if String Contains Substring in Python: in, find(), index(), count(), and Regex
June 23, 2026 - ... Use exact casing when case matters, such as product codes, file extensions, or protocol names. Use lower() for simple ASCII-style checks. Use casefold() for more robust case-insensitive matching.
🌐
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

🌐
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.
🌐
TutorialsPoint
tutorialspoint.com › how-do-i-do-a-case-insensitive-string-comparison-in-python
How do I do a case-insensitive string comparison in Python?
June 10, 2025 - str1 = "Tutorialspoint" str2 = "TUTORIALSPOINT" if str1.upper() == str2.upper(): print("The strings are equal i.e., case-insensitive") else: print("The strings are not equal") ... The casefold() method in Python is similar to the lower() method, but the difference is caseless matching, which is useful for comparing strings containing special characters or Unicode.
🌐
Polars
docs.pola.rs › py-polars › html › reference › expressions › api › polars.Expr.str.contains.html
polars.Expr.str.contains — Polars documentation
To modify regular expression behaviour (such as case-sensitivity) with flags, use the inline (?iLmsuxU) syntax. For example: >>> pl.DataFrame({"s": ["AAA", "aAa", "aaa"]}).with_columns( ... default_match=pl.col("s").str.contains("AA"), ... insensitive_match=pl.col("s").str.contains("(?i)AA"), ...