Skip to content

Instantly share code, notes, and snippets.

@btseytlin
Created June 23, 2021 13:06
Show Gist options
  • Select an option

  • Save btseytlin/4b9f9d1d491178ac99fbb33acaf59700 to your computer and use it in GitHub Desktop.

Select an option

Save btseytlin/4b9f9d1d491178ac99fbb33acaf59700 to your computer and use it in GitHub Desktop.
Medium "How to actually forecast COVID-19" embed
df_smoothed = df.rolling(7).mean().round(5)
df_smoothed.columns = [col + '_ma7' for col in df_smoothed.columns]
full_df = pd.concat([df, df_smoothed], axis=1)
for column in full_df.columns:
if column.endswith('_ma7'):
original_column = column.strip('_ma7')
full_df[column] = full_df[column].fillna(full_df[original_column])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment