title: Date ranges in Pandas
body: <p>After fighting with NumPy and dateutil for days, I recently discovered the amazing Pandas library. I've been poring through the documentation and source code, but I can't figure out how to get <code>date_range()</code> to generate indices at the right breakpoints.</p>
  
  <pre><code>from datetime import date
  import pandas as pd
  
  start = date('2012-01-15')
  end = date('2012-09-20')
  # 'M' is month-end, instead I need same-day-of-month
  date_range(start, end, freq='M')
  </code></pre>
  
  <p>What I want:</p>
  
  <pre><code>2012-01-15
  2012-02-15
  2012-03-15
  ...
  2012-09-15
  </code></pre>
  
  <p>What I get:</p>
  
  <pre><code>2012-01-31
  2012-02-29
  2012-03-31
  ...
  2012-08-31
  </code></pre>
  
  <p>I need month-sized chunks that account for the variable number of days in a month. This is possible with dateutil.rrule:</p>
  
  <pre><code>rrule(freq=MONTHLY, dtstart=start, bymonthday=(start.day, -1), bysetpos=1)
  </code></pre>
  
  <p>Ugly and illegible, but it works. How can do I this with pandas? I've played with both <code>date_range()</code> and <code>period_range()</code>, so far with no luck.</p>
  
  <p>My actual goal is to use <code>groupby</code>, <code>crosstab</code> and/or <code>resample</code> to calculate values for each period based on sums/means/etc of individual entries within the period. In other words, I want to transform data from:</p>
  
  <pre><code>                total
  2012-01-10 00:01    50
  2012-01-15 01:01    55
  2012-03-11 00:01    60
  2012-04-28 00:01    80
  
  #Hypothetical usage
  dataframe.resample('total', how='sum', freq='M', start='2012-01-09', end='2012-04-15') 
  </code></pre>
  
  <p>to</p>
  
  <pre><code>                total
  2012-01-09          105 # Values summed
  2012-02-09          0   # Missing from dataframe
  2012-03-09          60
  2012-04-09          0   # Data past end date, not counted
  </code></pre>
  
  <p>Given that Pandas originated as a financial analysis tool, I'm virtually certain that there's a simple and fast way to do this. Help appreciated!</p>