本文整理汇总了Python中taxcalc.Calculator.calc_all_test方法的典型用法代码示例。如果您正苦于以下问题:Python Calculator.calc_all_test方法的具体用法?Python Calculator.calc_all_test怎么用?Python Calculator.calc_all_test使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类taxcalc.Calculator
的用法示例。
在下文中一共展示了Calculator.calc_all_test方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run
# 需要导入模块: from taxcalc import Calculator [as 别名]
# 或者: from taxcalc.Calculator import calc_all_test [as 别名]
def run():
parm = Policy()
assert parm.current_year == 2013
recs = Records(data=TAX_DTA, weights=WEIGHTS, start_year=2009)
calc = Calculator(policy=parm, records=recs)
assert calc.current_year == 2013
totaldf = calc.calc_all_test()
totaldf = totaldf.T.groupby(level=0).first().T # drop duplicates
exp_results_file = os.path.join(CUR_PATH, '../../exp_results.csv.gz')
exp_results = pd.read_csv(exp_results_file, compression='gzip')
exp_set = set(exp_results.columns) # fix-up to bad colname in exp_results
cur_set = set(totaldf.columns)
assert(exp_set == cur_set)
for label in exp_results.columns:
lhs = exp_results[label].values.reshape(len(exp_results))
rhs = totaldf[label].values.reshape(len(exp_results))
res = np.allclose(lhs, rhs, atol=1e-02)
if not res:
print('Problem found in: ', label)
示例2: run
# 需要导入模块: from taxcalc import Calculator [as 别名]
# 或者: from taxcalc.Calculator import calc_all_test [as 别名]
def run():
"""
Run each function defined in Calculator.calc_all_test method using
'puf.csv' input and writing ouput to a CSV file named 'results_puf.csv'.
"""
# create a Policy object containing current-law policy (clp) parameters
clp = Policy()
# create a Records object (puf) containing puf.csv input records
tax_dta = pd.read_csv('puf.csv')
blowup_factors = './taxcalc/StageIFactors.csv'
weights = './taxcalc/WEIGHTS.csv'
puf = Records(tax_dta, blowup_factors, weights)
# create a Calculator object using clp policy and puf records
calc = Calculator(policy=clp, records=puf)
# save calculated test results in output dataframe (odf)
odf = calc.calc_all_test()
odf = odf.T.groupby(level=0).first().T
# write test output to csv file named 'results_puf.csv'
odf.to_csv('results_puf.csv', float_format='%1.3f',
sep=',', header=True, index=False)