1

df:

Column1  Column2
1        Balneolaeota;
2        Caldiserica;
3        Calditrichaeota;
4        Candidatus Abawacabacteria;
5        candidatus Adlerbacteria;


I want to delete all rows that contain the string "Candidatus" and "candidatus" in the second column.

Any advice?

1 Answer 1

3

You can use str.contains:

df = df[~df['Column2'].str.contains('candidatus', case=False)]

Out[1]: 
   Column1          Column2
0        1     Balneolaeota
1        2      Caldiserica
2        3  Calditrichaeota
Sign up to request clarification or add additional context in comments.

1 Comment

df = df.loc[~df['Column2'].str.contains('candidatus', case=False)] ;)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.