title: Better way to aggregate timestamped data?
body: <p>I am working with non-uniformly collected, timestamp indexed data and will eventually be computing statistics on a per minute, per hourly basis.  I'm wondering what the best way to aggregate by time periods is.</p>
  
  <p>I currently compute two lambda functions and then add two columns to the dataframe like so:</p>
  
  <pre><code>h = lambda i: pd.to_datetime(i.strftime('%Y-%m-%d %H:00:00'))
  m = lambda i: pd.to_datetime(i.strftime('%Y-%m-%d %H:%M:00'))
  df['hours'] = df.index.map(h)
  df['minutes'] = df.index.map(m)
  </code></pre>
  
  <p>This allows me to aggregate easily with <code>groupby</code> like so:</p>
  
  <pre><code>by_hour = df.groupby('hours')
  </code></pre>
  
  <p>I'm sure there is a better or more pythonic way to do this, but I haven't figured it out and would appreciate any help.</p>