0

I am working on a dataset and there is a particular column "Current Outstanding" which has both positive and negative values.I want to iterate through this column and use comparison operators to assign "High" or "low" values based on the positive/negative signs of the column values.

Dataset snippet is added below, check "Current Outstanding" column

enter image description here

My code:

def risk_predictor(i):
    for i in data['Current Outstanding']:
        if i >0:
            data['Risk_Level']='Low'
        elif i <0 and i >=data['Current Outstanding'].mean():
            data['Risk_Level']='Medium'
        elif i<data['Current Outstanding']:
            data['Risk_Level']='High'
            
risk_predictor(data['Current Outstanding'])

I want something like:

Low
Medium
High

in a new column data['Risk_Level'].

I tried going through Google but couldn't find any helpful solutions.

James Z
  • 12,104
  • 10
  • 27
  • 43

0 Answers0