How can I remove 2 labels from this array?

Question:

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)
Asked By: TenThousand

||

Answers:

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]

Answered By: Jules G.M.
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.