Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pandas: AttributeError: 'function' object has no attribute 'contains'

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!

like image 268
Edamame Avatar asked Sep 07 '25 16:09

Edamame


1 Answers

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)]
like image 196
Joe T. Boka Avatar answered Sep 10 '25 06:09

Joe T. Boka