title: how to get the sum of data till a particular date in pandas
body: <p>I have a sample dataframe (Date is in YYYY-MM-DD format)</p>
  <pre><code>Region  Area  Hq   Sales  Date               monthyear
    R1     A1   H1   1000   2020-01-01           202001
    R1     A1   H1   2000   2020-01-05           202001
    R1     A1   H1   1500   2020-01-09           202001
    R1     A1   H1   2000   2020-01-12           202001
    R1     A1   H1   2000   2020-01-17           202001
    R1     A1   H1   1300   2020-01-21           202001
    R1     A1   H1   1000   2020-01-23           202001
    R1     A1   H1   5000   2020-01-27           202001
  </code></pre>
  <p>From 1st day of month to 9th Day, the total sales value should be calculated</p>
  <p>From 10th day of month to 18th day, the total sales value should be calculated</p>
  <p>From 19th day of month to 24th day, the total sales value should be calculated</p>
  <p>From 25th day of month to 28th day, the total sales value should be calculated</p>
  <p>The desired output:</p>
  <pre><code>Region    Area  Hq    Sales    till_date    month_year
   R1        A1   H1     4500       9th          202001
   R1        A1   H1     4000       18th         202001
   R1        A1   H1     2300       24th         202001
   R1        A1   H1     5000       28th         202001
  </code></pre>
  <p>As you can see, we don't have <strong>2020-01-10</strong>, but we are taking from 2020-01-10 to 2020-01-18th range. So we are taking <strong>12th, 17th's</strong> which falls into that range. Likewise the rest.</p>
  <p>Another example ( only one record )</p>
  <pre><code>Region   Area    Hq    Sales    Date          monthyear
  H1        A1     H1    1000     2020-01-01     202001
  </code></pre>
  <p>The desired output</p>
  <pre><code>Region  Area    Hq     Sales     till_date      monthyear
   H1       A1    H1     1000      2020-01-09       202001
  </code></pre>
  <p>Before result, the sales is created at 2020-01-01, but it falls in 1st-9th</p>
  <p>dates range, the till_date is 2020-01-09.</p>
  <p>Additional Explanation:</p>
  <pre><code>Region  Area   Hq    Sales     Date         monthyear
   H1     A1     H1    2000     2020-01-31      202001
  </code></pre>
  <p>Desired output:</p>
  <pre><code>Region Area   Hq      Sales    till_date   monthyear
   H1     A1    H1        0       NaN           202001
  </code></pre>
  <p>Because 31st didn't fall in any of the range, so there's no till_date</p>
  <p>I've been trying this a lot but it didn't work out for me. So looking for your help.</p>
  <p>Thanks in Advance!</p>