Tax-Calculator IO#

Tax-Calculator IO

taxcalc.taxcalcio#

class taxcalc.taxcalcio.TaxCalcIO(input_data, tax_year, baseline, reform, assump, outdir=None)[source]#

Constructor for the Tax-Calculator Input-Output class.

TaxCalcIO class constructor call must be followed by init() call.

Parameters:
  • input_data (string or Pandas DataFrame) – string is name of INPUT file that is CSV formatted containing variable names in the Records USABLE_READ_VARS set, or Pandas DataFrame is INPUT data containing variable names in the Records USABLE_READ_VARS set. INPUT vsrisbles not in the Records USABLE_READ_VARS set can be present but are ignored.

  • tax_year (integer) – calendar year for which taxes will be computed for INPUT.

  • baseline (None or string) – None implies baseline policy is current-law policy, or string is name of optional BASELINE file that is a JSON reform file.

  • reform (None or string) – None implies no policy reform (current-law policy), or string is name of optional REFORM file(s).

  • assump (None or string) – None implies economic assumptions are standard assumptions, or string is name of optional ASSUMP file.

  • outdir (None or string) – None implies output files written to current directory, or string is name of optional output directory

Returns:

class instance

Return type:

TaxCalcIO

analyze(writing_output_file=False, output_tables=False, output_graphs=False, dump_varset=None, output_dump=False, output_sqldb=False)[source]#

Conduct tax analysis.

Parameters:
  • writing_output_file (boolean) – whether or not to generate and write output file

  • output_tables (boolean) – whether or not to generate and write distributional tables to a text file

  • output_graphs (boolean) – whether or not to generate and write HTML graphs of average and marginal tax rates by income percentile

  • dump_varset (set) – custom set of variables to include in dump and sqldb output; None implies include all variables in dump and sqldb output

  • output_dump (boolean) – whether or not to replace standard output with all input and calculated variables using their Tax-Calculator names

  • output_sqldb (boolean) – whether or not to write SQLite3 database with two tables (baseline and reform) each containing same output as written by output_dump to a csv file

Return type:

Nothing

custom_dump_variables(tcdumpvars_str)[source]#

Return set of variable names extracted from tcdumpvars_str, which contains the contents of the tcdumpvars file in the current directory. Also, builds self.errmsg if any custom variables are not valid.

dump_output(calcx, dump_varset, mtr_inctax, mtr_paytax)[source]#

Extract dump output and return it as Pandas DataFrame.

minimal_output()[source]#

Extract minimal output and return it as Pandas DataFrame.

output_filepath()[source]#

Return full path to output file named in TaxCalcIO constructor.

tax_year()[source]#

Return calendar year for which TaxCalcIO calculations are being done.

static write_decile_table(dfx, tfile, tkind='Totals')[source]#

Write to tfile the tkind decile table using dfx DataFrame.

write_doc_file()[source]#

Write reform documentation to text file.

static write_empty_graph_file(fname, title, reason)[source]#

Write HTML graph file with title but no graph for specified reason.

write_graph_files()[source]#

Write graphs to HTML files. All graphs contain same number of filing units in each quantile.

write_output_file(output_dump, dump_varset, mtr_paytax, mtr_inctax)[source]#

Write output to CSV-formatted file.

write_sqldb_file(dump_varset, mtr_paytax, mtr_inctax, mtr_paytax_base, mtr_inctax_base)[source]#

Write dump output to SQLite3 database table dump.

write_tables_file()[source]#

Write tables to text file.