Add new Commerce EDA Poverty import - #2178
Open
shvngisingh wants to merge 21 commits into
Open
shvngisingh wants to merge 21 commits into
shvngisingh wants to merge 21 commits into
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request introduces a new data importer for the Commerce EDA Poverty dataset, which tracks Persistent Poverty Counties. It includes metadata, mapping files, generated outputs, and a preprocessing script (process_poverty.py). The review feedback identifies two key issues: a hardcoded absolute project path in the preprocessing script that will cause failures in other environments, and an incorrect place type (AdministrativeArea1 instead of County) in the commented-out metadata configuration.
shvngisingh
force-pushed
the
commerce_eda_poverty_import
branch
from
August 24, 2026 07:53
5248291 to
1196449
Compare
…verage, and update README
… remove gitignore
…ator, and harden pipeline
saanikaaa
reviewed
Sep 14, 2026
…ty rates, untrack output/counters, rename metadata/pvmap, add test fixtures
…data/Poverty_input.csv
…g.error+raise, add validation rule descriptions
…schedule, map variableMeasured directly in pvmap, reject XX000 FIPS, restore GCS retries, and add survey year guard
saanikaaa
reviewed
Sep 18, 2026
saanikaaa
reviewed
Sep 18, 2026
saanikaaa
reviewed
Sep 18, 2026
saanikaaa
left a comment
Contributor
There was a problem hiding this comment.
If this is new import, we should have a CL as well to bring textproto. Mcf and dataset info about this import
… document semi-automated GCS setup in README
- Add download_poverty.py (and download.py alias) to dynamically discover and download the Persistent Poverty Counties Excel workbook directly from the Treasury CDFI Fund website with retries and exponential backoff - Refactor process_poverty.py to ingest the downloaded source file locally from input_files/ and eliminate all GCS bucket dependencies - Add download_poverty_test.py and update process_poverty_test.py with unit tests for download, retry, and local file preprocessing - Update manifest.json scripts to execute download_poverty.py followed by process_poverty.py - Update README.md to document the automated source download and preprocessing workflow
…verty Counties dataset - Add download_poverty.py (and download.py alias) to download the official EDA_FY23_PPCs.xlsx dataset directly from EDA website or archive mirror with retries, and support local --input_file - Extract Underlying_Data sheet from EDA_FY23_PPCs.xlsx to input_files/Poverty.csv and stage output/Poverty_original.csv - Refactor process_poverty.py to dynamically resolve source file (local Excel or CSV) and dynamically detect header row containing GEOID - Standardize 5-digit county GEOIDs (filtering state summary 01000 codes) and partition poverty_rate_recent into 2020 (island territories) and 2021 (states, DC, PR) - Restore 3,232-county dataset coverage across 1990, 2000, 2020, and 2021 observation dates - Restore validation_config.json thresholds for full county coverage (3100-3250 places, 9000-10000 observations) - Restore test fixtures test_data/Poverty_input.csv and test_data/Poverty_expected_output.csv - Add comprehensive unit tests in download_poverty_test.py and process_poverty_test.py (all 22 passing) - Update README.md and manifest.json with EDA provenance and usage instructions
… Poverty - Remove check_deleted_records_percent for new import (FINDING-P1-01) - Remove deceptive test fixture fallback from download and process scripts (FINDING-P2-01) - Add golden_summary_report.csv and wire check_goldens_summary_report rule (FINDING-P2-02) - Include output/*.mcf and counters/* in manifest.json source_files (FINDING-P2-03) - Refactor download_poverty.py to use requests session retry adapter and fast fail on 404 (FINDING-P2-04) - Add Troubleshooting Runbook and GCP credential prerequisite to README.md (FINDING-P2-05) - Wrap long lines (>100 chars) in config and test files (FINDING-P3-01) - Add PEP 8 import blank line separations (FINDING-P3-02) - Close openpyxl workbooks and requests sessions in try-finally blocks (FINDING-P3-03) - Remove unused output_dir flag definition (FINDING-P3-04) - Rename check_num_observations_check to check_num_observations_count (FINDING-P3-05)
…olden_data directory
…A Poverty - Eliminate dual-layered retry loop in download_poverty.py and rely on requests HTTPAdapter ([P3-01]) - Add standalone CLI test runner bootstrap to download_poverty_test.py and update transport mock tests ([P3-02]) - Use file handle for df.to_csv and robust cleanup on exception in process_poverty.py ([P3-03])
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
[PR #2178] Commerce EDA Poverty: Automated Persistent Poverty County Import
1. Overview
This PR introduces an automated, end-to-end import pipeline for the Commerce EDA Persistent Poverty Counties (PPC) dataset (
statvar_imports/commerce_eda_poverty/), decoupling the import from legacy manual Google Cloud Storage staging and transitioning to an autonomous, web-sourced ingestion pipeline.The dataset provides benchmarked county-level poverty percentage rates published by the U.S. Economic Development Administration (EDA) across statutory periods:
poverty_rate_1990)poverty_rate_2000)poverty_rate_2020for territories60,66,69,78)poverty_rate_2021for all 50 states, DC, and Puerto Rico)2. Key Architecture & Pipeline Components
download_poverty.py/download.py):EDA_FY23_PPCs.xlsxworkbook directly from EDA (https://www.eda.gov/sites/default/files/2023-03/EDA_FY23_PPCs.xlsx).--input_filefor local workbook or CSV ingestion.Underlying_Dataworksheet (3,241 raw county rows) intoinput_files/Poverty.csvand stagesoutput/Poverty_original.csv.process_poverty.py):geoId/XXXXX) and 2-digit island territory codes (geoId/XX).XX000FIPS).output/Poverty_cleaned.csv.stat_var_processor.py):Count_Person_BelowPovertyLevelInThePast12Months_AsFractionOf_Count_Personoutput/Poverty_output.csvandoutput/Poverty_output.tmcf.manifest.json):cron_schedule: "30 05 * * 1").3. Dataset & Statistical Variable Details
dcid:Count_Person_BelowPovertyLevelInThePast12Months_AsFractionOf_Count_Persondcid:Persondcid:countdcid:Count_Persondcid:BelowPovertyLevelInThePast12MonthsPercent/1004. Validation Configuration (
validation_config.json)The validation config enforces dataset integrity, geographic completeness, and bounds:
check_percent_min_value&check_percent_max_value: Verifies poverty percentages are withincheck_num_places_count(NUM_PLACES_COUNT): Asserts county coverage is between 3,100 and 3,250 places (safeguard against unintended data truncation).check_num_observations_check(NUM_OBSERVATIONS_CHECK): Asserts total observation count across benchmark years is between 9,000 and 10,000.check_max_date_consistent: EnsuresMaxDateis uniform across places.check_date_span_sql(DuckDBSQL_VALIDATOR): AssertsMinDate = 1990andMaxDate BETWEEN 2021 AND 2026.check_missing_refs_count: Enforces 0 unresolved entity or schema references.check_lint_error_count: Enforces 0 MCF/TMCF lint errors.check_deleted_records_percent: Allows at most 0.1% deleted records across refreshes.5. Review Comments Addressed
test_data/Poverty_input.csv,test_data/Poverty_expected_output.csv).variableMeasureddirectly todcs:Count_Person_BelowPovertyLevelInThePast12Months_AsFractionOf_Count_Personinpoverty_pvmap.csv.process_poverty.pyrated 9.80/10 with 0 warnings.6. Verification & Testing
./run_tests.sh -p statvar_imports/commerce_eda_poverty):0 fatal, 0 error(s)