I have a dataframe called tf_df
that has several columns, including one called 'Val_Combined'
. I want to create a new dataframe out of the items where ``Val_Combinedcontain the string
'VALID'` (it may contain other characters as well). I have tried the following:
t1_valid_df = t1_df[(t1_df['Val_Combined'].contains('VALID'))]
This throws an error:
AttributeError: 'Series' object has no attribute 'contains'
What is the correct approach to achieve my goal?
You should use str.contains
try this.
t1_valid_df = t1_df[(t1_df['Val_Combined'].str.contains('VALID'))]