Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,5 @@ db/data/stats_nz/regional_council_2025_codes/regional-council-2025-codes.json bi
db/data/stats_nz/territorial_authority_2025_codes/territorial-authority-2025-codes.json binary
db/data/stats_nz/national_population_estimates_2025/national-population-estimates-at-30-june-2025-landing-page.html binary
db/data/mbie/tenancy_bond_rents_tla_2026/detailed-monthly-tla-tenancy-september.csv binary
db/data/irs_soi/county_2023/23incyallnoagi.csv binary
db/data/irs_soi/congressional_district_2023/23incd.csv binary
1 change: 1 addition & 0 deletions changelog.d/irs-filing-season-week21-week30.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add the IRS filing-season cycle 21 and 30 tables for tax years 2024 and 2025. Each snapshot includes 116 published counts and amounts for all returns and 16 adjusted gross income bands, with the processing cutoff and original workbook cells.
1 change: 1 addition & 0 deletions changelog.d/irs-soi-2023-geography.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add tax year 2023 IRS county and congressional district observations using the geography and column definitions in the 2023 files.
1 change: 1 addition & 0 deletions changelog.d/irs-soi-w2-annual.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add IRS Form W-2 reported tips and traditional and Roth 401(k) contribution totals for tax years 2021 through 2023.
3,633 changes: 3,633 additions & 0 deletions chronicle/dimension_values/canonical_labels.json

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions chronicle/source_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -1079,13 +1079,22 @@
"soi-table-2-5-eitc-agi-children-2023": Path(
"irs_soi/table_2_5_eitc_agi_children_2023"
),
**{
f"soi-filing-season-week{week}-{year}": Path(
f"irs_soi/filing_season_week{week}_{year}"
)
for week in (21, 30)
for year in (2024, 2025)
},
"soi-filing-season-week47-2024-eitc-total": Path(
"irs_soi/filing_season_week47_2024"
),
"soi-table-4-3": Path("irs_soi/table_4_3"),
"soi-state-2022": Path("irs_soi/state_2022"),
"soi-county-2022": Path("irs_soi/county_2022"),
"soi-county-2023": Path("irs_soi/county_2023"),
"soi-congressional-district-2022": Path("irs_soi/congressional_district_2022"),
"soi-congressional-district-2023": Path("irs_soi/congressional_district_2023"),
"soi-historic-table-2": Path("irs_soi/historic_table_2"),
"soi-historic-table-2-state-agi-2022": Path(
"irs_soi/historic_table_2_state_agi_2022"
Expand All @@ -1099,6 +1108,7 @@
"soi-historic-table-2-state-eitc-2022": Path(
"irs_soi/historic_table_2_state_eitc_2022"
),
"soi-w2-statistics": Path("irs_soi/w2_statistics"),
"soi-w2-statistics-2020": Path("irs_soi/w2_statistics_2020"),
"soi-ira-traditional-contributions-2022": Path(
"irs_soi/ira_traditional_contributions_2022"
Expand Down
41 changes: 24 additions & 17 deletions chronicle/sources/admin_packages.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import csv
from datetime import datetime
from decimal import Decimal, InvalidOperation
from functools import partial
from io import BytesIO, StringIO
from pathlib import Path
import re
Expand Down Expand Up @@ -48,11 +49,13 @@ def ignore_aliases(self, data: Any) -> bool:
return True


def build_irs_soi_county_package(root: Path = REPO_ROOT) -> dict[str, Any]:
"""Build the TY2022 IRS SOI county package mapping from its CSV rows."""
data_dir = root / "db/data/irs_soi/county_2022"
def build_irs_soi_county_package(
root: Path = REPO_ROOT, *, year: int = 2022
) -> dict[str, Any]:
"""Build the annual IRS SOI county package mapping from its CSV rows."""
data_dir = root / f"db/data/irs_soi/county_{year}"
manifest = _load_yaml(data_dir / "manifest.yaml")
artifact = _year_file(manifest, 2022)
artifact = _year_file(manifest, year)
fixture = bool(artifact.get("fixture"))
headers, source_rows = _read_csv(data_dir / artifact["filename"])
_require_headers(
Expand Down Expand Up @@ -110,7 +113,7 @@ def build_irs_soi_county_package(root: Path = REPO_ROOT) -> dict[str, Any]:
"geography_id": f"0500000US{county_fips}",
"geography_level": "county",
"geography_name": county_name,
"geography_vintage": "2022",
"geography_vintage": str(year),
"expected_row_header_column": name_column,
"expected_row_header": county_name,
"filters": {"filing_status": "all", "income_range": "all"},
Expand Down Expand Up @@ -140,11 +143,11 @@ def build_irs_soi_county_package(root: Path = REPO_ROOT) -> dict[str, Any]:
if fixture
else "full publisher CSV row parse with selected county source-row lineage"
)
record_set_id = "irs_soi.ty2022.county_totals"
record_set_id = f"irs_soi.ty{year}.county_totals"
return {
"schema_version": schema_id("source_package"),
"package_id": IRS_PACKAGE_ID,
"label": f"{fixture_prefix}IRS SOI 2022 county return and AGI totals",
"package_id": f"soi-county-{year}",
"label": f"{fixture_prefix}IRS SOI {year} county return and AGI totals",
"fixture": fixture,
"generated_by": GENERATED_BY,
"dimension_labels": {
Expand All @@ -158,31 +161,31 @@ def build_irs_soi_county_package(root: Path = REPO_ROOT) -> dict[str, Any]:
},
"artifact": {
"source_name": source_name,
"source_table": f"{fixture_prefix}IRS SOI County Data 2022",
"source_table": f"{fixture_prefix}IRS SOI County Data {year}",
"resource_package": "db",
"resource_directory": "data/irs_soi/county_2022",
"resource_directory": f"data/irs_soi/county_{year}",
"manifest": "manifest.yaml",
"vintage": "tax_year_2022",
"vintage": f"tax_year_{year}",
"extracted_at": _artifact_extracted_date(artifact),
"extraction_method": extraction_method,
"parser": "delimited_text_full_rows",
"sheet_name": "22incyallnoagi",
"sheet_name": f"{year % 100:02d}incyallnoagi",
"selected_rows": selected_rows,
**({} if fixture else {"artifact_year": 2022}),
**({} if fixture else {"artifact_year": year}),
},
"record_sets": [
{
"record_set_id": record_set_id,
"provenance_class": "administrative",
"record_set_spec_id": "irs_soi.county_totals.v1",
"source_record_id_prefix": record_set_id,
"sheet_name": "22incyallnoagi",
"sheet_name": f"{year % 100:02d}incyallnoagi",
"period_type": "tax_year",
"period": "2022",
"period": str(year),
"geography_id": "0100000US",
"geography_level": "country",
"geography_name": "United States",
"geography_vintage": "2022",
"geography_vintage": str(year),
"entity": "tax_unit",
"entity_role": "filing_unit",
"domain": "all_individual_income_tax_returns",
Expand Down Expand Up @@ -223,7 +226,7 @@ def build_irs_soi_county_package(root: Path = REPO_ROOT) -> dict[str, Any]:
"for individual income tax returns; IRC section 62 "
"defines adjusted gross income."
),
"legal_vintage": "tax_year_2022",
"legal_vintage": f"tax_year_{year}",
"unit": "usd",
"aggregation": "sum",
"value_scale": 1000,
Expand Down Expand Up @@ -589,6 +592,10 @@ def build_usda_snap_monthly_package(root: Path = REPO_ROOT) -> dict[str, Any]:

PACKAGE_BUILDERS: dict[str, tuple[Path, Callable[[Path], dict[str, Any]]]] = {
IRS_PACKAGE_ID: (IRS_PACKAGE_PATH, build_irs_soi_county_package),
"soi-county-2023": (
Path("packages/irs_soi/county_2023/source_package.yaml"),
partial(build_irs_soi_county_package, year=2023),
),
PEP_PACKAGE_ID: (PEP_PACKAGE_PATH, build_census_pep_county_package),
SNAP_PACKAGE_ID: (SNAP_PACKAGE_PATH, build_usda_snap_monthly_package),
}
Expand Down
Loading
Loading