title: Pandas, dataframe with a datetime64 column, querying by hour
body: <p>I have a pandas dataframe <code>df</code> which has one column constituted by <code>datetime64</code>, e.g.</p>
  
  <pre><code>&lt;class 'pandas.core.frame.DataFrame'&gt;
  Int64Index: 1471 entries, 0 to 2940
  Data columns (total 2 columns):
  date    1471  non-null values
  id      1471  non-null values
  dtypes: datetime64[ns](1), int64(1)
  </code></pre>
  
  <p>I would like to sub-sample <code>df</code> using as criterion the hour of the day (independently on the other information in <code>date</code>). E.g., in pseudo code</p>
  
  <pre><code>df_sub = df[ (HOUR(df.date) &gt; 8) &amp; (HOUR(df.date) &lt; 20) ]
  </code></pre>
  
  <p>for some function <code>HOUR</code>.</p>
  
  <p>I guess the problem can be solved via a preliminary conversion from <code>datetime64</code> to <code>datetime</code>. Can this be handled more efficiently?</p>