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

How can I remove 2 labels from this array?

I’m very new to Python and I’m trying to remove ‘Low Risk’ and ‘Medium Risk’ from an array. Below is the code I’m
using:

    test=totalapproved_df[totalapproved_df['grossapproved_label']!='Low Risk']

    test['grossapproved_label'].unique()

Result:

    array(['Medium Risk', 'High Risk'], dtype=object)

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 :

You can use binary boolean logic operators, like the following

low_risk_mask = totalapproved_df['grossapproved_label'] != 'Low Risk'
medium_risk_mask = totalapproved_df['grossapproved_label'] != 'Medium Risk'
final_mask = low_risk_mask & medium_rism_mask
test = totalapproved_df[final_mask]

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