I have a python pandas dataframe df with lots of rows. Of these rows, I want to cut and use only rows containing the word "ball" in the column "body". For this I can do:
df[df['body'].str.contains('ball')]
The problem is that I want it to be case insensitive, which means that if the word Ball or bAll appeared, I would also want to. One way to make case-insensitive is to turn the string into lower case, and then search in this way. I am wondering how to do this. I tried
df[df['body'].str.lower().contains('ball')]
But that does not work. I'm not sure if I should use a lambda function on this or something like that.
python string pandas
David
source share