I have a dataframe. I want to slice it by checking if the value contains a string. For example, this code works:
data_df[data_df['column1'].str.contains('test')]
But I first want to set my column1 to be all lowercase first. So being the n00b that I am, I tried:
data_df[data_df['column1'].lower().str.contains('test')]
Of course the Python gods gave me no mercy and gave me an AttributeError. Any tips on how I can slice a dataframe based on a substring but first make everything into lowercase first?
I feel like the following post is very close to my answer but I can't get it to work exactly how I described up there: Python pandas dataframe slicing, with if condition
Thanks Python pros!!!
lower()as well:data_df[data_df['column1'].str.lower().str.contains('test')]