Issue 1140 loss rate rounding (#1170)

* updated loss rate rounding

* fixing a typo in variable name

* fixing typo in variable name

* oops, now ready to push

* updated pickle with float for loss rate columns

* updated a typo, now multiplies all loss rates by 100 consistent with other pcts

* updated with final pickles, all tests passing

* updated incorporating lucas pr comments

* changed literal to field name
This commit is contained in:
Emma Nechamkin 2022-01-26 13:57:45 -05:00 committed by GitHub
parent c6642ce586
commit 4c7d729cf7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 2 deletions

View file

@ -69,12 +69,20 @@ PERCENT_PREFIXES_SUFFIXES = [
"percent", "percent",
"Percentage", "Percentage",
"Energy burden", "Energy burden",
"loss rate",
"greater than or equal to 18 years", "greater than or equal to 18 years",
field_names.PERCENTILE_FIELD_SUFFIX, field_names.PERCENTILE_FIELD_SUFFIX,
] ]
TILES_ROUND_NUM_DECIMALS = 2 TILES_ROUND_NUM_DECIMALS = 2
# FEMA rounding columns
FEMA_ROUND_NUM_COLUMNS = [
field_names.EXPECTED_BUILDING_LOSS_RATE_FIELD,
field_names.EXPECTED_AGRICULTURE_LOSS_RATE_FIELD,
field_names.EXPECTED_POPULATION_LOSS_RATE_FIELD,
]
TILES_FEMA_ROUND_NUM_DECIMALS = 4
# Tiles data: full field name, tile index name # Tiles data: full field name, tile index name
TILES_SCORE_COLUMNS = { TILES_SCORE_COLUMNS = {
field_names.GEOID_TRACT_FIELD: "GTF", field_names.GEOID_TRACT_FIELD: "GTF",

View file

@ -259,6 +259,16 @@ class PostScoreETL(ExtractTransformLoad):
pd.to_numeric(df_100, errors="coerce") pd.to_numeric(df_100, errors="coerce")
).astype("Int64") ).astype("Int64")
df[column] = df_int df[column] = df_int
elif column in constants.FEMA_ROUND_NUM_COLUMNS:
# Convert loss rates by multiplying by 100 (they are percents)
# and then rounding appropriately.
df_100 = df[column] * 100
df[column] = floor_series(
series=df_100.astype(float64),
number_of_decimals=constants.TILES_FEMA_ROUND_NUM_DECIMALS,
)
else: else:
# Round all other floats. # Round all other floats.
df[column] = floor_series( df[column] = floor_series(