Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Pandas dp dropping row with mutiple strings

I am trying to drop a row with mutiple string patterns from a csv file a single pattern works but when adding another pattern it doesn’t work and does nothing to the file

ols = df[df["Risk"].str.contains("Not") == False] this works

ols = df[df["Risk"].str.contains("Not | yes") == False] this doesn’t work

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

IIUC remove spaces in "Not|yes", for compare with False invert mask by ~:

df[~df["Risk"].str.contains("Not|yes")] 
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading