pandas check match string lowercase 1

pandas check match string lowercase

# credit to the Stack Overflow user in the source link
# (?i) is the regex patter to tell the re module to ignore case
df["check"] = df["str_type_col"].str.contains("(?i)your_string")

Here is what the above code is Doing:
1. Create a new column called “check”
2. Use the str.contains() method to check if the string in the “str_type_col” column contains the string “your_string”
3. The (?i) tells the re module to ignore case
4. The result is a boolean value (True or False)

Similar Posts