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]