Home > Software design >  How to increment a value in a dictionary in Python using a proportion?
How to increment a value in a dictionary in Python using a proportion?

Time:09-17

I have the following parameter:

policy_params["ub_2"]["rs"]

which gives the following assigned values:

 Out[62]: {1: 416, 2: 374, 3: 332, 4: 316, 5: 296, 6: 240}

My question is how to change it by applying a 10% increase in the parameter's values (rs) above?

policy_params_new = copy.deepcopy(policy_params)

for n in policy_params_new["ub_2"]["rs"]:
    policy_params_new["ub_2"]["rs"][n]  = 

This last line is what I cannot adjust to increment a 10% increase

CodePudding user response:

You could try division:

for n in policy_params_new["ub_2"]["rs"]:
    policy_params_new["ub_2"]["rs"][n]  = policy_params_new["ub_2"]["rs"][n] / 10
  • Related