I have a csv file with a lot of data, and I have to print out all the rows that match with multiple conditions, there are 3 columns need to be focused on.
In the ‘description’ columns, I need to find all rows contain six different values and they are ‘Physically active’, ‘Anxiety disorder’, ‘Daily smokers’, ‘Diabetes’, ‘Healthy weight’, and ‘Self-rated health – very good’.
For the ‘group’ column, I need to match with exact word ‘total’, df.group.str.contains doesn’t work because there are also values like ‘total man’.
Also in the ‘population’ column, the word ‘adult’ must be matched too
Sorry it might be confused but I can’t post pictures yet, Please help, thanks.
Advertisement
Answer
df[df.ColumnName == "exact word to match"]