Enable observed impacts to be overwritten with NaN

This is useful where we have a structure or rock wall and want to specify that we don't know what the observed storm regime is. In this case, we'll put a 'unknown' string in the ./data/raw/profile_features observed storm impact csv field and overwrite it with a NaN in our pandas dataframe.
develop
Chris Leaman 6 years ago
parent ba9b3244f3
commit 557c15df1f

@ -218,9 +218,21 @@ def overwrite_impacts(df_observed_impacts, df_raw_features):
:param df_raw_profile_features:
:return:
"""
df_observed_impacts.update(
df_raw_features.rename(columns={"observed_storm_regime": "storm_regime"})
)
# Get manually specified impacts from the profile features ./data/raw/ folder. Note that sites which need to be
# overwritten with a NaN, use the string 'none' in the csv. This is because when we use the df.update() command,
# it doesn't overwrite NaN values. So we'll put in the 'none' string, then overwrite that with the NaN.
df_overwritten_impacts = df_raw_features.rename(
columns={"observed_storm_regime": "storm_regime"}
).storm_regime.to_frame()
df_observed_impacts.update(df_overwritten_impacts)
# Replace 'none' with nan
df_overwritten_impacts.loc[
df_overwritten_impacts.storm_regime == "unknown", "storm_regime"
] = np.nan
return df_observed_impacts

Loading…
Cancel
Save