I have the following code to check if the value of certain column contains the given string:
my_df[my_df.name.str.contains('Mike')]
However, when I tried to make it work for all letter cases like:
my_df[my_df.name.str.lower.contains('mike')]
I got the following error:
AttributeError: 'function' object has no attribute 'contains'
What should be the correct way to call the lower() function, so I can make sure the match is case insensitive? Thanks!
You can use the boolean parameter case
. It's set to True
by default, which is case sensitive. Thus, you should set it to False
. Pandas Documentation
my_df[my_df.name.str.contains('Mike', case=False)]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With