title: Moving Average for python issue
body: <p>I am looking at corona data from the NY Times which can be found here: <a href="https://raw.githubusercontent.com/nytimes/covid-19-data/master/us-counties.csv" rel="nofollow noreferrer">https://raw.githubusercontent.com/nytimes/covid-19-data/master/us-counties.csv</a></p>
  
  <p>And open for everyone to use. </p>
  
  <p>The dataset is set up like this:</p>
  
  <pre><code>df = pd.read_csv('https://raw.githubusercontent.com/nytimes/covid-19-data/master/us-counties.csv')
  df2 = df.copy()
  df2 = df2.set_index('date')
  df2['cases_lagged'] = df2.groupby(['county', 'state'])['cases'].shift()
  df2[df2['fips']== 34041.0].head(10)
  </code></pre>
  
  <p>I was hoping I could create a moving average column the same way using a groupby statement along with the .rolling() command from pandas to compile a 7-day and 14-day moving average for the data but it does not work. </p>
  
  <p>I tried it two separate ways:</p>
  
  <pre><code>#way 1
  df2['moving_avg'] = df2.groupby(['county', 'state']).iloc[:4].rolling(window = 7).mean()
  
  #way 2
  df2['moving_avg'] = df2.groupby(['county', 'state'])['cases'].rolling(window = 7).mean()
  </code></pre>
  
  <p>And neither seems to work here.</p>
  
  <p>Any thoughts on how to compile the moving average for each county within each state without having to break out each and every county into its own df for it to work? Thanks</p>