Search code examples
pythondictionaryincrementproportions

How to increment a value in a dictionary in Python using a proportion?


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


Solution

  • 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