title: Splitting data into batches conditional on cumulative sum
body: <p>I'm trying to batch some data based on a <code>start_date</code> and <code>end_date</code> that is conditional of the cumulative sum of which is &lt;= 500000.
  Say I have a simple data frame with two columns:</p>
  <pre><code>index  Date            num_books
  0      2021-01-01       200000
  1      2021-01-02       240000
  2      2021-01-03       55000
  3      2021-01-04       400000
  4      2021-01-05       80000
  5      2021-01-06       100000
  </code></pre>
  <p>I need to do a cumulative sum of the values in <code>num_books</code> until it has &lt;= 500000 and record the start date, end date and the cumsum value. This is an example of what I'm trying to achieve</p>
  <pre><code>start_date  end_date   cumsum_books
  2021-01-01  2021-01-03  495000
  2021-01-04  2021-01-05  480000
  2021-01-06  2021-01-06  100000
  </code></pre>
  <p>Is there an efficient way/function to achieve this? Thank you!</p>