From c9ee6a43c1e51627ef885fcad94208e60cf1d0e0 Mon Sep 17 00:00:00 2001 From: Jorge Escobar Date: Mon, 3 Jan 2022 18:14:36 -0500 Subject: [PATCH] cdc_places update --- .../data_pipeline/etl/sources/cdc_places/etl.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/data/data-pipeline/data_pipeline/etl/sources/cdc_places/etl.py b/data/data-pipeline/data_pipeline/etl/sources/cdc_places/etl.py index 337c60ef..ad58a23d 100644 --- a/data/data-pipeline/data_pipeline/etl/sources/cdc_places/etl.py +++ b/data/data-pipeline/data_pipeline/etl/sources/cdc_places/etl.py @@ -2,6 +2,7 @@ import pandas as pd from data_pipeline.etl.base import ExtractTransformLoad from data_pipeline.utils import get_module_logger, download_file_from_url +from data_pipeline.score import field_names logger = get_module_logger(__name__) @@ -49,6 +50,20 @@ class CDCPlacesETL(ExtractTransformLoad): values=self.CDC_VALUE_FIELD_NAME, ) + # rename columns to be used in score + rename_fields = { + "Current asthma among adults aged >=18 years": field_names.ASTHMA_FIELD, # 'Current asthma among adults aged greater than or equal to 18 years' + "Coronary heart disease among adults aged >=18 years": field.names.HEART_DISEASE_FIELD, # "Coronary heart disease among adults aged greater than or equal to 18 years" + "Cancer (excluding skin cancer) among adults aged >=18 years": field_names.CANCER_FIELD, # 'Cancer (excluding skin cancer) among adults aged greater than or equal to 18 years', + "Diagnosed diabetes among adults aged >=18 years": field_names.DIABETES_FIELD, # 'Diagnosed diabetes among adults aged greater than or equal to 18 years', + "Physical health not good for >=14 days among adults aged >=18 years": field_names.PHYS_HEALTH_NOT_GOOD_FIELD, # 'Physical health not good for greater than or equal to 14 days among adults aged greater than or equal to 18 years', + } + self.df.rename( + columns=rename_fields, + inplace=True, + errors="raise", + ) + # Make the index (the census tract ID) a column, not the index. self.df.reset_index(inplace=True)