I am generating COVID-19 case time series for all US states with the below code. I'd like to add 7 and 14 day moving average to each time series/subplot.
here is some of the code:
#calculate daily change in covid cases per state with each state as a column in a time series
us_daily_change = united_states.diff()
#calculate the 7 and 14 day moving average per state
short_window = 7
long_window = 14
us_rolling_short_mean = us_daily_change.rolling(short_window).mean()
us_rolling_long_mean = us_daily_change.rolling(long_window).mean()
#this works to plot each state's cases but I can't incorporate the moving averages
us_daily_change.plot(subplots=True, layout=(6,9), figsize=(50,25))
#here's what i have tried. doesn't come close.
for i,j,k in zip(us_daily_change, us_rolling_short_mean, us_rolling_long_mean):
plt.plot([us_daily_change[i], us_rolling_short_mean[j], us_rolling_long_mean[k]])
plt.show()
plt.close()