Skip to main content

taxsim-py

taxsim-py is a dataframe-oriented Python implementation of NBER TAXSIM, independent of and not affiliated with NBER. It calculates federal income tax, payroll tax, and state income tax for household records, using Polars DataFrame or LazyFrame inputs and clear variable names (TAXSIM's v1-style names only on request).

Documentation · Try the calculator in your browser

Install

pip install taxsim-py

The wheels for Linux x86_64, Windows x64 and macOS include the compiled calculators that the default engine="rust" uses. On any other platform pip installs a Python-only wheel (use engine="python"), or build from source with Rust installed.

Basic use

Every row needs mstat and state (TAXSIM codes, or Census FIPS with state_id_type="fips"). Include year in the data or pass year=.

import polars as pl

from taxsim_py import calculate_taxes

households = pl.DataFrame(
    {
        "year": [2021, 2021],
        "state": [6, 36],       # California, New York
        "mstat": [1, 2],        # single, married filing jointly
        "page": [45, 50],
        "pwages": [50_000, 80_000],
        "swages": [0, 40_000],
        "depx": [0, 2],
    }
)

taxes = calculate_taxes(households)
print(taxes.select("fiitax", "fica", "siitax"))

The result is the input plus fiitax (federal income tax), fica (payroll taxes), siitax (state income tax) and other outputs, and frate/srate (marginal rates) when requested. Missing inputs default to zero (dep13, dep17 and dep18 default to depx). idtl=2 adds detailed federal and state worksheets, taxsim_names=True renames them to TAXSIM's labels, and keep_intermediate=True keeps every intermediate column for auditing.

Calculation modes

statutory (default) uses the canonical parameter tables and reviewed corrections to TAXSIM. calculation_mode="taxsim" reproduces the compiled TAXSIM, for replication and comparison; it is not recommended for new analysis.

In the browser

The calculator runs taxsim-py in the page through Pyodide: a form for one household, and a CSV upload for many. Nothing is sent to a server. From Python, taxsim_py.calculate_row({...}) takes a dict of TAXSIM inputs and returns a dict of inputs plus results.

Command line

taxsim-py households.csv taxes.parquet
taxsim-py households.dta                 # CSV on standard output
taxsim-py households.csv taxes.csv --mode taxsim --batch-rows 50000 --workers 4

File types come from the extensions: csv, tsv, parquet, arrow, ndjson, and Stata (dta), SPSS (sav, zsav) and SAS (sas7bdat, read only) with the optional reader (pip install "taxsim-py[readstat]", which adds polars-readstat). Use --input-format/--output-format when the extension is not useful and --lowercase for SAS files with uppercase names. The same readers are taxsim_py.io.tables.read_table and write_table.

What is supported

  • Years: federal tax 1960-2025 and state tax 1977-2025, all actual law. Other years raise an error.
  • States: all 50 states and DC (TAXSIM codes 1-51; 0 means no state). States without an income tax return 0, except Washington's Working Families credit in statutory mode.
  • Inputs: TAXSIM's 35 inputs, with the same meanings and units, plus the optional children_under_3, children_under_4 and children_under_7. Two conventions: psemp/ssemp get no qualified business income deduction (use pbusinc/pprofinc), and pensions is the kind of pension each state exempts.
  • Accuracy: in taxsim mode, to the cent against the compiled TAXSIM on the validation matrix, apart from logged TAXSIM errors. statutory mode follows the law where TAXSIM is wrong (Statutory corrections); its remaining differences from PolicyEngine-US (2022-2025) are in the PolicyEngine comparison.
  • Not modelled: items TAXSIM has no input for, such as 2025 deductions for tips, overtime and car-loan interest, and Washington's capital gains tax.
  • Speed: on a mixed 42-state batch, 1,000,000 rows including marginal rates take about 0.5 s and 1.1 GiB with the default compiled engine (engine="rust"), or 7.1 s and 2.8 GiB with the Python reference (engine="python", for developing and testing changes). The compiled TAXSIM takes 17.3 s. A LazyFrame input streams into any Polars sink with memory that depends mainly on the thread count, not the rows. See Performance.

Documentation

Start with the user guide. Also: Statutory corrections, Performance and PolicyEngine comparison.

To add a tax year, change the law or add an output, see Updating the tax law.

License

MIT; see LICENSE.

Metadata

Release files for taxsim-py 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for taxsim-py 0.4.0
File Size Uploaded
taxsim_py-0.4.0.tar.gz 587.8 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for taxsim-py 0.4.0
File
taxsim_py-0.4.0-py3-none-any.whl Python 3 none any Details
taxsim_py-0.4.0-cp39-abi3-win_amd64.whl CPython 3.9 abi3 Windows x86-64 Details
taxsim_py-0.4.0-cp39-abi3-manylinux_2_28_x86_64.whl CPython 3.9 abi3 Linux glibc 2.28+ x86-64 Details
taxsim_py-0.4.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.9 abi3 Linux glibc 2.17+ x86-64 Details
taxsim_py-0.4.0-cp39-abi3-macosx_11_0_arm64.whl CPython 3.9 abi3 macOS 11.0+ ARM64 Details
taxsim_py-0.4.0-cp39-abi3-macosx_10_15_x86_64.whl CPython 3.9 abi3 macOS 10.15+ x86-64 Details

Total release size: 27.8 MB

Release files / taxsim_py-0.4.0.tar.gz

Download URL taxsim_py-0.4.0.tar.gz
Size 587.8 kB
Tags Source
SHA-256 checksum
How to use checksums
ea42849b6e81c0b68373192c715f09a4c1d6cf661b7ea37146cab46cb8755054
BLAKE2b-256 checksum
How to use checksums
3ad75e9d5e5d0f3314c58f85e9dfe95a9d1076d91195cffc96546765fd225795
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / taxsim_py-0.4.0-py3-none-any.whl

Download URL taxsim_py-0.4.0-py3-none-any.whl
Size 487.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bb3aaf6059bf26c01d20659100e826d9d7756250c385dcf65807d6dbd5b32688
BLAKE2b-256 checksum
How to use checksums
e135eaf59f51c81d7544744718d6970d9ea890a7756bbf1f79cdb48bbd4b3909
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / taxsim_py-0.4.0-cp39-abi3-win_amd64.whl

Download URL taxsim_py-0.4.0-cp39-abi3-win_amd64.whl
Size 5.9 MB
Tags CPython 3.9 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
21821d89497be736eb3a88b0ea99991e275054c6d3f4a6f7a47bf7b2281d7c3c
BLAKE2b-256 checksum
How to use checksums
69ac2fb305f9fa5ff877ae31a73a959f2f29d4d365cd83ffd76eff6f7c798ef7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / taxsim_py-0.4.0-cp39-abi3-manylinux_2_28_x86_64.whl

Download URL taxsim_py-0.4.0-cp39-abi3-manylinux_2_28_x86_64.whl
Size 5.4 MB
Tags CPython 3.9 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
e90c6e71f1234d9467d2bb62c82b90a7eb49153bb88d4f9f4737bcc482df46b6
BLAKE2b-256 checksum
How to use checksums
01471cb5773e1f7ba25383e751607a0a46d62944fb668763d16118f74577cc88
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / taxsim_py-0.4.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL taxsim_py-0.4.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 5.4 MB
Tags CPython 3.9 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
6a23bdb2e5d00b6035fc0a570717332a376735ad5d010a548f8314a9d2d42c8c
BLAKE2b-256 checksum
How to use checksums
b6edc42577fb81ebcdbc5b8624558dc9c2c54be7a770deafbd483fe7434e68df
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / taxsim_py-0.4.0-cp39-abi3-macosx_11_0_arm64.whl

Download URL taxsim_py-0.4.0-cp39-abi3-macosx_11_0_arm64.whl
Size 4.9 MB
Tags CPython 3.9 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
62135bc24ddf6d66283a69f781bc6312d1a421eb2071fb533e65dfd01bce41c3
BLAKE2b-256 checksum
How to use checksums
ab12c61aa0991cad799f303551d75eefe5959c45eb2f8b6266bc9ff5ae9a6025
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / taxsim_py-0.4.0-cp39-abi3-macosx_10_15_x86_64.whl

Download URL taxsim_py-0.4.0-cp39-abi3-macosx_10_15_x86_64.whl
Size 5.2 MB
Tags CPython 3.9 abi3 macOS 10.15+ x86-64
SHA-256 checksum
How to use checksums
90a50d87fe52ecd9666c90338b4174e396773a0da79b56b0a06e18a2f3520e5a
BLAKE2b-256 checksum
How to use checksums
f7335e1c0fc216954745b8023b3d101b589a311d651cfdd5e0f2547615848323
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release history Release notifications | RSS feed

This release

0.4.0 This release

7 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page