title: Fast selection of a time interval in a pandas DataFrame/Series
body: <p>my problem is that I want to filter a DataFrame to only include times within the interval <em>[start, end)</em> . If do not care about the day, I would like to filter only for start and end time for each day. I have a solution for this but it is slow. So my question is if there is a faster way to do the time based filtering.</p>
  
  <p>Example</p>
  
  <pre><code>import pandas as pd
  import time
  
  
  index=pd.date_range(start='2012-11-05 01:00:00', end='2012-11-05 23:00:00', freq='1S').tz_localize('UTC')
  df=pd.DataFrame(range(len(index)), index=index, columns=['Number'])
  
  # select from 1 to 2 am, include day
  now=time.time()
  df2=df.ix['2012-11-05 01:00:00':'2012-11-05 02:00:00']
  print 'Took %s seconds' %(time.time()-now) #0.0368609428406
  
  # select from 1 to 2 am, for every day
  now=time.time()
  selector=(df.index.hour&gt;=1) &amp; (df.index.hour&lt;2)
  df3=df[selector]
  print 'Took %s seconds' %(time.time()-now) #Took  0.0699911117554
  </code></pre>
  
  <p>As you can see if I remove the day (second case) it takes almost twice as much. The computation time increases rapidly if I have a number of different days, e.g from 5 to 7 Nov:</p>
  
  <pre><code>index=pd.date_range(start='2012-11-05 01:00:00', end='2012-11-07 23:00:00', freq='1S').tz_localize('UTC')
  </code></pre>
  
  <p>So, to summarize is there a faster method to filter by time of the day, across many days?</p>
  
  <p>Thx</p>