diff --git a/src/analysis/observed_storm_impacts.py b/src/analysis/observed_storm_impacts.py index 754cfcd..b60acbf 100644 --- a/src/analysis/observed_storm_impacts.py +++ b/src/analysis/observed_storm_impacts.py @@ -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