From ec8f3543e54444630602a1e7c4ddb3fdbdf43129 Mon Sep 17 00:00:00 2001 From: Saran Ahluwalia Date: Wed, 24 Nov 2021 16:50:09 -0500 Subject: [PATCH 1/2] Remove Index related to FEMA (#917) Co-authored-by: Saran Ahluwalia --- .../data_pipeline/ipython/scoring_comparison.ipynb | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/data/data-pipeline/data_pipeline/ipython/scoring_comparison.ipynb b/data/data-pipeline/data_pipeline/ipython/scoring_comparison.ipynb index 477d2820..ac34f0fc 100644 --- a/data/data-pipeline/data_pipeline/ipython/scoring_comparison.ipynb +++ b/data/data-pipeline/data_pipeline/ipython/scoring_comparison.ipynb @@ -407,12 +407,7 @@ " method_name=\"Persistent Poverty (CBG)\",\n", " priority_communities_field=PERSISTENT_POVERTY_CBG_LEVEL_FIELD,\n", " other_census_tract_fields_to_keep=[],\n", - " ),\n", - " Index(\n", - " method_name=FEMA_COMMUNITIES,\n", - " priority_communities_field=FEMA_COMMUNITIES,\n", - " other_census_tract_fields_to_keep=[],\n", - " ),\n", + " )\n", " ]\n", ")\n", "\n", @@ -1726,7 +1721,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.6" + "version": "3.7.4" } }, "nbformat": 4, From b0c176daee5b912e92e184f13a0e88b54d5d34ee Mon Sep 17 00:00:00 2001 From: Saran Ahluwalia Date: Mon, 29 Nov 2021 13:27:23 -0500 Subject: [PATCH 2/2] Remove inplace argument to prevent SettingWithCopyError (#899) * removed inplace argument to prevent copies of dataframe to be set and chained assignment to propogate and raise exception * removed inplace argument to prevent copies of dataframe to be set and chained assignment to propogate and raise exception * remove superfluous pandas options that affects flake results * remove (again) the same chained assignment from previous merge Co-authored-by: Saran Ahluwalia --- .../data_pipeline/etl/score/etl_score_post.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/data/data-pipeline/data_pipeline/etl/score/etl_score_post.py b/data/data-pipeline/data_pipeline/etl/score/etl_score_post.py index 19bdc788..66c9e4d7 100644 --- a/data/data-pipeline/data_pipeline/etl/score/etl_score_post.py +++ b/data/data-pipeline/data_pipeline/etl/score/etl_score_post.py @@ -3,6 +3,7 @@ import pandas as pd from data_pipeline.etl.base import ExtractTransformLoad from data_pipeline.utils import get_module_logger, zip_files + from data_pipeline.etl.sources.census.etl_utils import ( check_census_data_source, ) @@ -102,11 +103,13 @@ class PostScoreETL(ExtractTransformLoad): """ # Rename some of the columns to prepare for merge new_df = initial_counties_df[constants.CENSUS_COUNTIES_COLUMNS] - new_df.rename( + + new_df_copy = new_df.rename( columns={"USPS": "State Abbreviation", "NAME": "County Name"}, - inplace=True, + inplace=False ) - return new_df + + return new_df_copy def _transform_states( self, initial_states_df: pd.DataFrame @@ -254,16 +257,16 @@ class PostScoreETL(ExtractTransformLoad): pdf_path = constants.SCORE_DOWNLOADABLE_PDF_FILE_PATH # Rename score column - downloadable_df.rename( + downloadable_df_copy = downloadable_df.rename( columns={"Score G (communities)": "Community of focus (v0.1)"}, - inplace=True, + inplace=False, ) logger.info("Writing downloadable csv") - downloadable_df.to_csv(csv_path, index=False) + downloadable_df_copy.to_csv(csv_path, index=False) logger.info("Writing downloadable excel") - downloadable_df.to_excel(excel_path, index=False) + downloadable_df_copy.to_excel(excel_path, index=False) logger.info("Compressing files") files_to_compress = [csv_path, excel_path, pdf_path]