This guide teaches you how to use the Open Source Policy Center's Tax Calculator. To follow along you will need the following:
In [1]:
import sys
sys.path.append("../../")
import taxcalc
from taxcalc import *
import pandas as pd
from pandas import DataFrame
In [2]:
# Default Plans
#Create a Public Use File object
tax_dta = pd.read_csv("../../puf.csv")
# Create a default Parameters object
params1 = Parameters(start_year=2013)
records1 = Records(tax_dta)
# Create a Calculator
calcX = Calculator(records=records1, params=params1)
In [3]:
calcX.calc_all()
In [4]:
tX = create_distribution_table(calcX, groupby="weighted_deciles", result_type="weighted_sum")
In [5]:
DIST_LABELS = ['Returns', 'AGI', 'Standard Deduction Filers',
'Standard Deduction', 'Itemizers',
'Itemized Deduction', 'Personal Exemption',
'Taxable Income', 'Regular Tax', 'AMTI', 'AMT Filers', 'AMT',
'Tax before Credits', 'Non-refundable Credits',
'Tax before Refundable Credits', 'Refundable Credits',
'Revenue']
In [6]:
tX.columns = DIST_LABELS
In [7]:
tX
Out[7]:
In [9]:
# User specified Plans
params2 = Parameters(start_year=2013)
#Create a Public Use File object
tax_dta = pd.read_csv("../../puf.csv")
# Create a default Parameters object
records2 = Records(tax_dta)
myvars = {}
myvars['_ID_StateLocalTax_HC'] = [1]
user_mods = {2013: myvars}
# Create a Calculator
calcY = calculator(params=params2, records=records2, mods=user_mods)
In [10]:
calcY.calc_all()
In [11]:
tY = create_distribution_table(calcY, groupby="weighted_deciles", result_type="weighted_sum")
In [12]:
tY.columns = DIST_LABELS
In [13]:
tY
Out[13]:
In [14]:
tdiff2013 = create_difference_table(calcX, calcY, groupby="weighted_deciles")
In [15]:
DIFF_TABLE_LABELS = ["Inds. w/ Tax Cut", "Inds. w/ Tax Increase", "Count",
"Mean Tax Difference", "Total Tax Difference",
"%age Tax Increase", "%age Tax Decrease",
"Share of Overall Change"]
tdiff2013.columns = DIFF_TABLE_LABELS
In [16]:
tdiff2013
Out[16]:
In [17]:
for i in range(3):
calcX.increment_year()
calcY.increment_year()
print calcX.current_year
print calcY.current_year
calcX.calc_all()
calcY.calc_all()
In [18]:
tdiff2016 = create_difference_table(calcX, calcY, groupby="weighted_deciles")
tdiff2016.columns = DIFF_TABLE_LABELS
tdiff2016
Out[18]:
In [ ]:
In [19]: