Created
December 7, 2020 21:46
-
-
Save clayh53/ae4771e1a59afa15f42357ea59ff52fc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# calculate an average death rate from lagged data | |
avg_death_from_positive_cases = df["death_prediction_scalar"].rolling(window=rolling_avg).mean() | |
stable_period = 45 | |
start = lag - stable_period # calculates the index from end of dataframe to start the calculation | |
death_factor = avg_death_from_positive_cases[start:lag].mean() # average of smoothed data | |
# copy death scalar to an entire column | |
df['avg_death_factor'] = [death_factor] * len(df.index) # copies value to entire column | |
df['predicted_death'] = df['positiveIncrease'] * df['avg_death_factor'] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment