Home > Software engineering >  How can I remove 2 labels from this array?
How can I remove 2 labels from this array?

Time:09-15

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)

CodePudding user response:

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]

  • Related