I have a column which rejected amounts (these are just 5 exmaples)
I want to add a column, given points based on the price.
For example, if price is betwen 0 and 100 -> 0.
what i did was :
dict_reject_amount = {0:0,\
range(1,101):1,\
range(101,201):2,\
range(201,301):3,\
range(301,401):4,\
range(401,501):5,\
range(501,601):6,\
range(601,701):7,\
range(701,801):8,\
range(801,901):9,\
range(901,100000):9}
convert to int, floats do not matter
new['rejected_int'] = new['rejected'].astype(int)
new['reject_amount_points']= new['rejected_int'].map(dict_reject_amount)
Unfortunately it didn’t work.
>Solution :
You can use replace to apply the dict values
new['reject_amount_points'] = df['rejected_int'].replace(dict_reject_amount)

