mirror of
https://github.com/DOI-DO/j40-cejst-2.git
synced 2025-02-22 17:44:20 -08:00
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:
parent
c6642ce586
commit
4c7d729cf7
3 changed files with 20 additions and 2 deletions
|
@ -69,12 +69,20 @@ PERCENT_PREFIXES_SUFFIXES = [
|
|||
"percent",
|
||||
"Percentage",
|
||||
"Energy burden",
|
||||
"loss rate",
|
||||
"greater than or equal to 18 years",
|
||||
field_names.PERCENTILE_FIELD_SUFFIX,
|
||||
]
|
||||
|
||||
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_SCORE_COLUMNS = {
|
||||
field_names.GEOID_TRACT_FIELD: "GTF",
|
||||
|
|
|
@ -259,6 +259,16 @@ class PostScoreETL(ExtractTransformLoad):
|
|||
pd.to_numeric(df_100, errors="coerce")
|
||||
).astype("Int64")
|
||||
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:
|
||||
# Round all other floats.
|
||||
df[column] = floor_series(
|
||||
|
|
Binary file not shown.
Loading…
Add table
Reference in a new issue