title: Problem with doing calculation using groupby in pandas but it links to other group
body: <p>Hi i have a dataframe which i groupby the quarter of the hour (q1 to q4) and then the hour of the day (hour 1 -24)
  I then want to perform a calculation based on each hour of each q and create a column call &quot;reg_rate&quot; which is based on an existing column &quot;reg_sta&quot; and is essentially 1 or -1.</p>
  <p>The calculation is to calculate the number of 1 presented in the past 7 days for each group i wanted, i.e. each hour and each q. The result for each group i would expect the first 7 days of data would be NA due to the fact that we need 7 days worth of data point before doing the calculation.</p>
  <p>here is my code</p>
  <pre><code>da = df.groupby([&quot;ValueMinuteCet&quot;,'ValueHourCet'])
  
  cond = df['Reg_sta'] &gt; 0
  df['reg_up'] = (cond.shift().rolling(7).sum())/7
  </code></pre>
  <p>What i found is that the first group of the data in &quot;reg_up&quot; is ok, then into the second group i would end up having the calculation linked to the last 7 days of &quot;reg_sta&quot; meaning i would have the data point straight in the first row of my second group. i.e. calculation is linked to previous group.</p>
  <p>Anyone knows how to perform this calculation and separating it from previous group?</p>
  <p>I just tried the following where i got an error with '&gt;' not supported between instances of 'SeriesGroupBy' and 'int'</p>
  <pre><code>da = df.groupby([&quot;ValueMinuteCet&quot;,'ValueHourCet'])
  
  cond = da['Reg_sta'] &gt; 0
  df['reg_up'] = (cond.shift().rolling(7).sum())/7
  </code></pre>