Source code for policy_modules.age_rating
#!/usr/bin/env python
import re
from utility_modules.get_parameters import get_params
import pandas as pd
import numpy as np
[docs]class Exchange:
def __init__(self, gid):
self.age_table = get_params(gid)
self.min_age= min(self.age_table.age)
self.max_age= max(self.age_table.age)
[docs] def inflate(self, premium, pop_df, expnd_choices, type, choice_types): # type= 6, 7, or 8
ex_idx = np.where(np.matrix(expnd_choices[choice_types] ==type))
pop_row= expnd_choices['hieu_idx'][ex_idx[1]]
v_age= pop_df[pop_row].age
rating = pd.merge(v_age, self.age_table, on = ["age"], how = "left")
ex_prem = (rating['rating'].values())* premium
zeros = np.zeros(expnd_choices.shape)
zeros[ex_idx]= ex_prem #fill in adjusted premiums for hieu_idx people
return (zeros.sum(axis=1))