Skip to content

Mexico_census_aa2|validation failure fix - #2140

Open
Ashwani725 wants to merge 27 commits into
datacommonsorg:masterfrom
Ashwani725:mexic_census_aa2
Open

Mexico_census_aa2|validation failure fix#2140
Ashwani725 wants to merge 27 commits into
datacommonsorg:masterfrom
Ashwani725:mexic_census_aa2

Conversation

@Ashwani725

@Ashwani725 Ashwani725 commented Aug 6, 2026

Copy link
Copy Markdown

Summary

Fixes auto-refresh validation failure for MexicoCensus_AA2 where the national-level output (mexico_output_aa0.csv) was generated with 0 data rows.

Root Cause

  1. Source Excel files use MX in ADM0_PCODE, which was missing from mexico_places.csv (which previously only resolved Mexico -> country/MEX).
  2. The 2024 data release introduced subtle schema shifts (Spanish header variants like ADM0_ES, column index 0, and accidental subnational columns in ADM0 sheets) and split senior age groups (65OrMoreYears in 2021 into 5-year buckets up to 85OrMoreYears in 2024).

Key Changes

  • Place Resolution (mexico_places.csv): Added MX -> country/MEX mapping and corrected missing slash formatting in Wikidata IDs (wikidataId/Q...).
  • Data Normalization (mexico_download.py): Added normalize_dataframe() to standardize headers (_ES -> _EN, digit header cleanup) and column order across 2021 and 2024 releases. Moved directory creation into the download method to ensure side-effect-free module imports.
  • Unit Testing (mexico_download_test.py): Added test coverage for normalize_dataframe covering ADM0, ADM1, ADM2, and non-ADM sheets.
  • Manifest & Automation (manifest.json): Configured --existing_statvar_mcf=gs://unresolved_mcf/scripts/statvar/stat_vars.mcf, --output_counters, and wildcard node_mcf inputs.
  • Validation (validation_config.json): Configured scoped SQL_VALIDATOR rules verifying MaxDate >= 2024 for active StatVars and MaxDate >= 2021 for legacy 65OrMoreYears StatVars.
  • Documentation & Test Data: Updated README.md CLI examples and updated testdata/mexico_output_aa0.csv with the 102 resolved observations.

Verification

CL link

@google-cla

google-cla Bot commented Aug 6, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds validation configuration, golden data, and counters for the Mexico subnational population statistics import. Specifically, it introduces validation rules in validation_config.json, adds several golden observation and summary report CSV files, includes counter files, updates mexico_places.csv to map 'MX' to country/MEX, and updates manifest.json to integrate these validation steps and output counters. I have no feedback to provide as there are no review comments and the changes appear correct.

@pulkeet-wq

Copy link
Copy Markdown
Contributor

Counter folder not required in Github. Please remove the folder and all file @Ashwani725

…o_census_aa2/counters/mexico_census_data_counters_0.csv

delete counter file as not required
…o_census_aa2/counters/mexico_census_data_counters_1.csv
…o_census_aa2/counters/mexico_census_data_counters_2.csv

@saanikaaa saanikaaa left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets add a better PR description

Ashwani725 and others added 5 commits September 3, 2026 12:31
Added header renaming and leading column definitions for standardizing dataframes. Implemented normalization function to standardize headers and column ordering for different release years.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants