forked from PSLmodels/ui_calculator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
minimum_working_example.py
36 lines (25 loc) · 1009 Bytes
/
minimum_working_example.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# -*- coding: utf-8 -*-
"""
Created on Tue May 12 09:22:20 2020
@author: probert2
"""
import pandas as pd
import numpy as np
import sys
sys.path.insert(0, 'source')
from ui_calculator import calc_weekly_state_quarterly
income_data = pd.read_csv("example_annual.csv")
income_data['weekly_earnings'] = income_data['wage']/income_data['weeks_worked']
def quarterly_earnings(annual_weeks, weekly_earnings, quarter_number):
quarter_weeks = annual_weeks - 52 + 13 * quarter_number
quarter_weeks = min(max(0, quarter_weeks), 13)
return quarter_weeks*weekly_earnings
v_quarterly_earnings = np.vectorize(quarterly_earnings)
for i in range(4):
income_data['q' + str(i + 1)] = v_quarterly_earnings(income_data['weeks_worked'], income_data['weekly_earnings'], i + 1)
income_data['benefits'] = calc_weekly_state_quarterly(
income_data['q1'],
income_data['q2'],
income_data['q3'],
income_data['q4'],
income_data['state'])