title: Using shift and rolling in pandas with groupBy
body: <pre><code>df = pd.DataFrame(dict(
      list(
          zip(["A", "B", "C"],
              [np.array(["id %02d" % i for i in range(1, 11)]).repeat(10),
              pd.date_range("2018-01-01", periods=100).strftime("%Y-%m-%d"),
              [i for i in range(10, 110)]])
          )
  ))
  
  df = df.groupby(["A", "B"]).sum()
  
  df["D"] = df["C"].shift(1).rolling(2).mean()
  
  df
  </code></pre>
  
  <p>This code generates the following:</p>
  
  <p><a href="https://i.stack.imgur.com/5aJ0e.png" rel="noreferrer"><img src="https://i.stack.imgur.com/5aJ0e.png" alt="enter image description here"></a></p>
  
  <p>I want the rolling logic to start over for every new ID. Right now, <code>ID 02</code> is using the last two values from <code>ID 01</code> to calculate the mean. </p>
  
  <p>How can this be achieved?</p>