health-code
Small helpers for preparing a rounded, masked mortality table for disclosure review.
Install the distribution health-code; import it as health.
from health import print_unique # also: from health.helpers import print_unique
print_unique is copied, with the same signature and behavior, from the LTC code package
(ltc_code.helpers.print_unique) so you do not need to install LTC.
Install
From PyPI:
uv pip install health-code
From a local wheel:
uv build # writes dist/health_code-0.1.0-py3-none-any.whl
uv pip install dist/health_code-0.1.0-py3-none-any.whl
Python 3.9 or newer. Dependencies: polars, xlsxwriter.
The example
After installing, copy the example script next to your work (it refuses to overwrite):
health-example my_scripts/ # or: health-example my_scripts/prepare_table.py
Edit the Settings block at the top and run it. It does this:
- Reads one parquet per year, 2001..2024, from
INPUT_FOLDER. The file name comes fromFILENAME_PATTERN, e.g.mortality_{year}.parquet. All 24 files must exist. - Keeps only the eight columns in
COLUMN_MAPand renames them toyear,sex,income_percentile,age,mortality_rate,deaths,n,n_weighted. Replace the*_placeholdernames with your real column names. - Fails on: a missing file, a missing column, different column types across files, a row whose
year is not its file's year, missing values, duplicate keys, ages outside
AGES, a rate outside 0..1,deaths > n,n <= 0, or non-positiven_weighted. - Rounds and masks (below) and writes the request folder.
You must set RATE_KIND ("weighted" or "unweighted") and REQUEST_DATE (YYYYMMDD). Neither
has a default, because a wrong guess would change what is released.
The same steps are available as functions: read_annual_parquets, prepare_disclosure,
write_disclosure, and round_count.
What gets written
Layout follows the FSRDC Disclosure Avoidance Review Procedures Handbook v7.0.0 (2026-08-03), section III.C:
YYYYMMDD/
output/Table_1_T13T26.xlsx the file to submit (rounded, masked)
support/Table_1_support_CUI_SP-CENS_T13T26.csv exact combined data
support/estimate_inventory_T13T26.xlsx row and estimate counts
support/rounding/README.txt how to run the official rounder
- Every xlsx has a first sheet named
CUIholding only the CUI header text. - The release is xlsx only, so the same estimates are not submitted in two formats. For a CSV copy
(for your own use), set
RELEASE_CSV_FOLDERto a folder outside the request folder. - The support CSV holds exact counts, survivors and the suppression flags. It is for the
supportfolder only. Only the eight mapped columns ever reach any output file. estimate_inventory_T13T26.xlsxleaves prior releases asUNKNOWN; fill them in from your project's output tracking sheet.- Existing files are never replaced unless
OVERWRITE = True. Nothing is deleted. support/rounding/is left for you: run the Census programdrb_rounder.pyfollowing the DRB Rounder Tutorial on RDC Docs and keep its_rounded.xlsxoutput. This package does not fake it.
Rounding and masking rules
From the FSRDC Disclosure Avoidance Methods Handbook (guidance current as of 2026-05-01), section V.B. Each count is rounded by its own size:
| count | rounded to |
|---|---|
| under 15 | suppressed |
| 15 to 99 | nearest 10 |
| 100 to 999 | nearest 50 |
| 1,000 to 9,999 | nearest 100 |
| 10,000 to 99,999 | nearest 500 |
| 100,000 to 999,999 | nearest 1,000 |
| 1,000,000 or more | four significant figures |
Exact ties: counts below 1,000,000 round half to even (25 -> 20, as in
oi_tools.drb.round_count_column); four-significant-figure rounding at 1,000,000 or more rounds
ties away from zero (1,234,500 -> 1,235,000). The handbook does not specify tie-breaking, so run
the official Census rounder before release. Weighted n_weighted is rounded to four significant
figures.
"unweighted": released rate = roundeddeaths/ roundedn, to four significant figures."weighted": released rate = your input rate to four significant figures. Deaths are never rebuilt from a weighted rate.
Suppression (a chosen conservative policy, not a universal Census minimum). A row's four numbers
(n, deaths, mortality_rate, n_weighted) are all set to blank when n < 15, deaths < 15,
n - deaths < 15, or an optional EXTRA_SUPPRESS condition is true. Zeros are suppressed too.
Keys stay, so the table keeps its shape, and the release has no column saying why a row is blank.
This package is not an approval. It does not check prior releases, the 30:1 volume rule, the
required minimum entity counts for your geography, or anything the disclosure officer reviews.
Run the official drb_rounder.py and follow your FSRDC administrator's current instructions.
Why not depend on oi-tools: it requires Python 3.10 or newer and this package targets 3.9. The
count rounding is a few lines of polars, and the tests check its thresholds against an independent
reference. round_proportion_column in oi-tools is not used (outdated rule).
Develop
uv sync
uv run python -m unittest discover -s tests -v
uv build
Tests use synthetic data only.
Metadata
Release files for health-code 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| health_code-0.1.0.tar.gz | 10.4 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| health_code-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 23.5 kB
Release files / health_code-0.1.0.tar.gz
| Download URL | health_code-0.1.0.tar.gz |
|---|---|
| Size | 10.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c60cc2bcf9d030952a5b08f74d048f84ea41f03cb221c947bcd396f06bf5241e
|
|
BLAKE2b-256 checksum How to use checksums |
8ecf47393964444d41e30f3c0d62eaabfeb55cfda19ba26b8725aa6b06d212ee
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / health_code-0.1.0-py3-none-any.whl
| Download URL | health_code-0.1.0-py3-none-any.whl |
|---|---|
| Size | 13.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d78eec0cebc66ce5dad4d6d57ee271ac714ea37175b6483d487e0f1e29f04fd3
|
|
BLAKE2b-256 checksum How to use checksums |
e040d0f3c43a5b06158f0628b4565e1366426b5fb659a03334468fba68ef48e0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for health-code 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.