-
Notifications
You must be signed in to change notification settings - Fork 10
/
policy.py
58 lines (48 loc) · 1.9 KB
/
policy.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
"""
Business-Taxation Policy class.
"""
import os
import pandas
import taxcalc
from biztax.years import START_YEAR, END_YEAR, NUM_YEARS
class Policy(taxcalc.Parameters):
"""
The Policy class is derived from the Tax-Calculator Parameters class,
and therefore, inherits its methods (none of which are shown here).
Constructor for the Business-Taxation Policy class, which
does not have any (wage or price) indexed parameters and
does not have any vector parameters.
Parameters:
none
"""
DEFAULTS_FILE_NAME = 'policy_current_law.json'
DEFAULTS_FILE_PATH = os.path.abspath(os.path.dirname(__file__))
def __init__(self):
# read default parameters and initialize
super().__init__()
self.initialize(START_YEAR, NUM_YEARS)
def implement_reform(self, reform,
print_warnings=True, raise_errors=True):
"""
Implement specified policy reform and leave current_year unchanged.
(see taxcalc.Parameters._update for argument documentation.)
"""
self._update(reform, print_warnings, raise_errors)
def parameters_dataframe(self):
"""
Return pandas DataFrame containing all parameters in
this Policy object (as columns) for each year (as rows)
in the [START_YEAR, END_YEAR] range.
But note that the returned DataFrame is indexed over the
[0, NUM_YEARS] range (not over calendar years even though
the DataFrame contains a year column).
Also, note that the leading underscore character in each
parameter name is removed in the returned DataFrame.
"""
pdict = dict()
btax_years = list(range(START_YEAR, END_YEAR + 1))
pdict['year'] = btax_years
for pname in self._vals:
parray = getattr(self, pname)
pdict[pname[1:]] = parray
return pandas.DataFrame(data=pdict)