-
Notifications
You must be signed in to change notification settings - Fork 147
Eurostat Data Import - Death by week and sex & Divorce indicators #2039
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
pravnkumar-cloudsufi
wants to merge
14
commits into
datacommonsorg:master
Choose a base branch
from
pravnkumar-cloudsufi:eurostat_data_death_divorce
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
2f00a9e
Eurostat_Data_Death_by_week_and_sex_and_Divorce_indicators_data
pravnkumar-code c443648
EurostatData_Deaths_by_week_and_sex_&_Divorce_indicators
pravnkumar-code 88b77cf
Eurostat Data Import Resolution of Gemini Checks
pravnkumar-code 1fd838b
Eurostat Data Import - Death by week and sex & Divorce indicators aft…
pravnkumar-code 9dd23a0
Eurostat Death by week and sex data import
pravnkumar-code ed0f470
Eurostat Death by week and sex data import
pravnkumar-code 399096e
Divorce Indicator Data Import and Modifed README file of Deaths by we…
pravnkumar-code edb6391
Divorce Indicator RUN.sh script corrected
pravnkumar-code 4dc0247
Fix path for places_resolved_csv in run.sh
pravnkumar-cloudsufi 63197a5
Eurostat Data Import Deaths by week and sex
pravnkumar-code f09004b
Eurostat Data Import Divorce Indicators
pravnkumar-code 400b96d
Eurostat Data Marriage by sex and previous marital status and Populat…
pravnkumar-code 69769ed
Adding input folder
pravnkumar-cloudsufi 075963b
Death by week and sex pvmap change for removing unit Person
pravnkumar-cloudsufi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
2 changes: 2 additions & 0 deletions
2
statvar_imports/eurostat/Deaths_by_week_and_sex/Deaths_by_week_and_sex_metadata.csv
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| parameter,value | ||
| header_rows,1 |
39 changes: 39 additions & 0 deletions
39
statvar_imports/eurostat/Deaths_by_week_and_sex/Deaths_by_week_and_sex_pvmap.csv
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| key,property1,value1,property2,value2,property3,value3,property4,value4 | ||
|
|
||
| # Global Dataflow properties (Standard Data Commons Mortality Modeling) | ||
| "DATAFLOW:ESTAT:DEMO_R_MWK_TS(1.0)",populationType,dcs:MortalityEvent,measuredProperty,dcs:count,statType,dcs:measuredValue,, | ||
|
|
||
| # --- AUTOMATED CLEANUP: Ignored Columns --- | ||
| LAST UPDATE,#ignore,"",,,,,, | ||
| CONF_STATUS,#ignore,"",,,,,, | ||
|
|
||
| # Frequency dimension (P1W is standard for weekly duration) | ||
| freq:W,observationPeriod,P1W,,,,,, | ||
|
|
||
| # Sex / Gender dimension | ||
| sex:T,gender,"",,,,,, | ||
| sex:M,gender,dcs:Male,,,,,, | ||
| sex:F,gender,dcs:Female,,,,,, | ||
|
|
||
| # Geography dimension (Using direct passing) | ||
| geo,observationAbout,{Data},,,,,, | ||
|
|
||
| # Safely ignore the old week string so it doesn't cause errors | ||
| TIME_PERIOD,#ignore,"",,,,,, | ||
|
|
||
| # Map the new YYYY-MM-DD column directly | ||
| CALENDAR_DATE,observationDate,{Data},,,,,, | ||
|
|
||
| # Observation Value (FIXED: Restored the missing value mapping) | ||
| OBS_VALUE,value,{Number},,,,,, | ||
|
|
||
| # Safely Ignoring Transient Status Flags to Prevent Ingestion Warnings | ||
| OBS_FLAG:p,#ignore,"",,,,,, | ||
| OBS_FLAG:e,#ignore,"",,,,,, | ||
| OBS_FLAG:b,#ignore,"",,,,,, | ||
| OBS_FLAG:f,#ignore,"",,,,,, | ||
| OBS_FLAG:n,#ignore,"",,,,,, | ||
| OBS_FLAG:u,#ignore,"",,,,,, | ||
|
|
||
| # Missing values | ||
| OBS_FLAG:M,MissingValue,"",,,,,, |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| # Eurostat Deaths By Week And Sex Import | ||
|
|
||
| ## Overview | ||
| This dataset contains weekly death indicators at national and regional levels, sourced from Eurostat. The data tracks the total number of deaths broken down by sex and week across various European countries and regions. | ||
|
|
||
| **type of place:** Country, NUTS Regions (Level 0-3) | ||
| **years:** Historical data to present (2000-present, recorded weekly e.g., 2000-W01) | ||
| **place_resolution:** Resolved to DCIDs (e.g., dcid:country/FRA, dcid:nuts/AT113) | ||
|
|
||
| ## Data Source | ||
| **Source URL:** | ||
| https://ec.europa.eu/eurostat/databrowser/view/demo_r_mwk_ts/default/table?lang=en | ||
|
|
||
| **Provenance Description:** | ||
| The data is provided by Eurostat, the statistical office of the European Union. It belongs to the "Demography, population stock and balance" database under the "Deaths by week - special data collection" statistical theme, specifically the "Deaths by week and sex" (DEMO_R_MWK_TS) dataset. | ||
|
|
||
| ## Refresh Type | ||
| Automatic Refresh | ||
|
|
||
| The refresh is automated using the provided `run.sh` script, which handles both data download and processing. | ||
|
|
||
| ## How To Run Import | ||
| To execute the complete import process (download and processing), run: | ||
| ./run.sh | ||
|
|
||
| ### Script Details: | ||
| - **Download**: Uses `curl` to fetch the latest SDMX-CSV data from Eurostat's dissemination API. | ||
| - **Processing**: Uses `stat_var_processor.py` to map raw data to Data Commons StatVarObservations using the PV map and metadata configuration. | ||
|
|
||
| ## Key Files | ||
| - `run.sh`: Main execution script for download and processing. | ||
| - `Deaths_by_week_and_sex_pvmap.csv`: Property-Value mapping for StatVar definitions and dimensions. | ||
| - `Deaths_by_week_and_sex_metadata.csv`: Configuration parameters for the processor. | ||
| - `places_resolved.csv`: Mapping of place codes to Data Commons DCIDs. | ||
| - `Deaths_by_week_and_sex_output.csv`: Processed statistical observations. | ||
| - `Deaths_by_week_and_sex_output.tmcf`: Template MCF mapping the CSV columns to Data Commons schema. | ||
|
|
||
| ## Validation | ||
| To validate the generated data, use the Data Commons import tool (lint mode): | ||
| ```bash | ||
| java -jar datacommons-import-tool.jar lint Deaths_by_week_and_sex_output.csv Deaths_by_week_and_sex_output.tmcf | ||
| ``` | ||
| The resulting reports (`report.json`, `summary_report.html`) in `dc_generated/` provide detailed insights into data quality and validation status. | ||
|
|
||
| ## Testing | ||
| Testing is performed using the `test_data` directory: | ||
| - Raw Input: `test_data/Deaths_by_week_and_sex_data_raw.csv` | ||
| - Raw Processed Input: `test_data/Deaths_by_week_and_sex_data_raw_processed` | ||
| - Expected Output: `test_data/Deaths_by_week_and_sex_output.csv` | ||
| - Expected TMCF: `test_data/Deaths_by_week_and_sex_output.tmcf` | ||
|
|
||
| ## Run to Process the test data | ||
| python3 ../../../tools/statvar_importer/stat_var_processor.py \ | ||
| "--input_data=./test_data/Deaths_by_week_and_sex_data_raw_processed.csv" \ | ||
| "--pv_map=./Deaths_by_week_and_sex_pvmap.csv" \ | ||
| "--config_file=./Deaths_by_week_and_sex_metadata.csv" \ | ||
| "--generate_statvar_name=True" \ | ||
| "--skip_constant_csv_columns=False" \ | ||
| "--output_columns=observationDate,observationAbout,variableMeasured,value,observationPeriod,measurementMethod,unit,scalingFactor" \ | ||
| "--output_path=./final_output/Deaths_by_week_and_sex_output" \ | ||
| "--places_resolved_csv=./places_resolved.csv" \ | ||
| "--existing_statvar_mcf=gs://unresolved_mcf/scripts/statvar/stat_vars.mcf" | ||
|
|
||
| ## Run to Process the full data | ||
| python3 ../../../tools/statvar_importer/stat_var_processor.py \ | ||
| "--input_data=./input_files/Deaths_by_week_and_sex_data_raw_processed.csv" \ | ||
| "--pv_map=./Deaths_by_week_and_sex_pvmap.csv" \ | ||
| "--config_file=./Deaths_by_week_and_sex_metadata.csv" \ | ||
| "--generate_statvar_name=True" \ | ||
| "--skip_constant_csv_columns=False" \ | ||
| "--output_columns=observationDate,observationAbout,variableMeasured,value,observationPeriod,measurementMethod,unit,scalingFactor" \ | ||
| "--output_path=./final_output/Deaths_by_week_and_sex_output" \ | ||
| "--places_resolved_csv=./places_resolved.csv" \ | ||
| "--existing_statvar_mcf=gs://unresolved_mcf/scripts/statvar/stat_vars.mcf" |
32 changes: 32 additions & 0 deletions
32
statvar_imports/eurostat/Deaths_by_week_and_sex/convert_week_to_date.py
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| # Copyright 2026 Google LLC | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # You may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and limitations under the License. | ||
|
|
||
| import pandas as pd | ||
| import os | ||
| from datetime import datetime | ||
|
|
||
| # Get the absolute path of the directory where this script is located | ||
| # (Which is now the Deaths_by_week_and_sex folder) | ||
| script_dir = os.path.dirname(os.path.abspath(__file__)) | ||
|
|
||
| # Since the data is in the same folder as the script, we just append the filenames | ||
| input_file = os.path.join(script_dir, 'Deaths_by_week_and_sex_data_raw.csv') | ||
| output_file = os.path.join(script_dir, 'Deaths_by_week_and_sex_data_raw_processed.csv') | ||
|
|
||
| # Load your raw data | ||
| df = pd.read_csv(input_file) | ||
|
|
||
| # Convert YYYY-Wxx to the Sunday of that week (ISO format: %G = Year, %V = Week, %u = Day of Week) | ||
| df['CALENDAR_DATE'] = df['TIME_PERIOD'].apply( | ||
| lambda x: datetime.strptime(x + '-7', "%G-W%V-%u").strftime("%Y-%m-%d") | ||
| ) | ||
|
|
||
| # Save the updated CSV to use in your importer | ||
| df.to_csv(output_file, index=False) | ||
|
|
||
| print(f"Data successfully processed and saved to:\n{output_file}") | ||
26 changes: 26 additions & 0 deletions
26
statvar_imports/eurostat/Deaths_by_week_and_sex/manifest.json
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| { | ||
| "import_specifications": [ | ||
| { | ||
| "import_name": "EuroStat_Deaths_by_week_and_sex", | ||
| "curator_emails": [ | ||
| "support@datacommons.org" | ||
| ], | ||
| "provenance_url": "https://ec.europa.eu/eurostat/databrowser/view/demo_r_mwk_ts/default/table?lang=en", | ||
| "provenance_description": "This data is a voluntary, granular collection of weekly deaths by sex, age, and region across European countries from 2000 onward, established by Eurostat to monitor mortality trends during and after the COVID-19 pandemic.", | ||
| "scripts": [ | ||
| "run.sh" | ||
| ], | ||
| "source_files": [ | ||
| "input_files/*.csv" | ||
| ], | ||
| "import_inputs": [ | ||
| { | ||
| "template_mcf": "final_output/Deaths_by_week_and_sex_output.tmcf", | ||
| "cleaned_csv": "final_output/Deaths_by_week_and_sex_output.csv" | ||
| } | ||
| ], | ||
| "cron_schedule": "5 1 1,15 * *", | ||
| "resource_limits": {"cpu": 4, "memory": 8, "disk":100} | ||
| } | ||
| ] | ||
| } |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.