title: Count number of weeks using pandas groupby
body: <p>I have the following sample dataframe: </p>
  
  <pre><code>Date                count_row   Work_Type
  2018-07-31 00:00:00 1           logpage
  2018-08-01 00:00:00 1           logpage
  2018-08-01 00:00:00 1           logpage
  2018-08-01 00:00:00 1           logpage
  2018-08-01 00:00:00 1           logpage
  2018-09-02 00:00:00 1           logpage
  2018-09-02 00:00:00 1           logpage
  2018-09-03 00:00:00 1           logpage
  2018-09-04 00:00:00 1           logpage
  2018-09-04 00:00:00 1           logpage
  2018-09-06 00:00:00 1           logpage
  2018-09-07 00:00:00 1           logpage
  2018-09-08 00:00:00 1           logpage
  </code></pre>
  
  <p>I want to break it down into weeks and count the number of occurrences in that week.  Specifically, I consider the beginning of the week to be Monday and the end of the week to be Sunday.  </p>
  
  <p>For instance, 9/3/2018 is a Monday (or what I consider to be the beginning of week).  So anything from that Monday to the following Sunday I count for 9/3/2018.  </p>
  
  <p>Below is the dataframe result I am looking for: </p>
  
  <pre><code>Beginning of Week Date (Mon)    count
  7/30/2018                       5
  8/27/2018                       2
  9/3/2018                        6
  </code></pre>
  
  <p>I tried the following code: </p>
  
  <pre><code>df.set_index('Date', inplace=True)
  df.sort_index(inplace=True)
  
  def take_first(array_like):
      return array_like[0]
  
  output = df.resample('W',                  
                      how={'Date': take_first, 
                           'count_row': 'sum'}, 
                      loffset=pd.offsets.timedelta(days=-6))
  </code></pre>
  
  <p>This is the error I get: </p>
  
  <pre><code>IndexError: index out of bounds
  </code></pre>