Skip to content

Commit

Permalink
Add summary file
Browse files Browse the repository at this point in the history
  • Loading branch information
nikhilwoodruff committed Feb 9, 2024
1 parent 8e3ae3d commit 6f34a1e
Show file tree
Hide file tree
Showing 2 changed files with 137 additions and 0 deletions.
32 changes: 32 additions & 0 deletions tax_microdata_benchmarking/create_summary_file.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
from tax_microdata_benchmarking.create_flat_file import taxcalc_extension
from policyengine_us import Simulation
import pandas as pd
from pathlib import Path

sim = Simulation(reform=taxcalc_extension, situation={"person_id": 1})
taxcalc_cps = pd.read_csv("cps.csv.gz")

summary_file = """# PolicyEngine US Tax-Calculator flat file
This file contains a summary of the Tax-Calculator microdata file. It is intended to be used as a reference for the Tax-Calculator microdata file.
"""

added_columns = []

variables = sim.tax_benefit_system.variables
for variable in variables.values():
if variable.name.startswith("tc_"):
added_columns.append(variable.name[3:])

# Add 'The flat file currently has X out of Y (Z%) columns in the Tax-Calculator CPS microdata file'.

summary_file += f"\nThe flat file currently has {len(added_columns)} out of 68 ({len(added_columns) / len(taxcalc_cps.columns):.0%}) columns in the Tax-Calculator CPS microdata file.\n"

for variable in variables.values():
if variable.name.startswith("tc_"):
summary_file += f"\n## {variable.name[3:]}\n\n{variable.label}\n\n"

FOLDER = Path(__file__).parent

with open(FOLDER / "summary.md", "w") as file:
file.write(summary_file)
105 changes: 105 additions & 0 deletions tax_microdata_benchmarking/summary.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
# PolicyEngine US Tax-Calculator flat file

This file contains a summary of the Tax-Calculator microdata file. It is intended to be used as a reference for the Tax-Calculator microdata file.

The flat file currently has 20 out of 68 (29%) columns in the Tax-Calculator CPS microdata file.

## RECID

record ID


## MARS

filing status


## e00200p

wages less pension contributions (filer)


## e00200s

wages less pension contributions (spouse)


## e00200

TaxCalc Variable Alias


## age_head

age of head of tax unit


## age_spouse

age of spouse of head of tax unit


## blind_head

blindness of head of tax unit


## blind_spouse

blindness of spouse of head of tax unit


## fips

FIPS state code


## s006

tax unit weight


## FLPDYR

tax year to calculate for


## EIC

EITC-qualifying children


## nu18

number of people under 18


## n1820

number of people 18-20


## nu13

number of people under 13


## nu06

number of people under 6


## n24

number of people eligible for the CTC


## elderly_dependents

number of elderly dependents


## f2441

CDCC-qualifying children

0 comments on commit 6f34a1e

Please sign in to comment.