title: How to fetch hours from m8[ns] object in pandas?
body: <p>I have a dataframe like shown below</p>
  
  <pre><code>df = pd.DataFrame({'time':['2166-01-09 14:00:00','2166-01-09 14:08:00','2166-01-09 16:00:00','2166-01-09 20:00:00',
                         '2166-01-09 04:00:00','2166-01-10 05:00:00','2166-01-10 06:00:00','2166-01-10 07:00:00','2166-01-10 11:00:00',
                         '2166-01-10 11:30:00','2166-01-10 12:00:00','2166-01-10 13:00:00','2166-01-10 13:30:00']})
  </code></pre>
  
  <p>I am trying to find a time difference between rows. For which I did the below</p>
  
  <pre><code>df['time2'] = df['time'].shift(-1)
  df['tdiff'] = (df['time2'] - df['time'])
  </code></pre>
  
  <p>So, my result looks like as shown below</p>
  
  <p><a href="https://i.stack.imgur.com/gU9kR.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gU9kR.png" alt="enter image description here"></a></p>
  
  <p>I found out that there exists a function like <code>dt.days</code> and I tried</p>
  
  <pre><code>df['tdiff'].dt.days
  </code></pre>
  
  <p>but it only gives the day component but am looking for something like 'hours` component</p>
  
  <p>However, I would like to have my output like as shown below</p>
  
  <p><a href="https://i.stack.imgur.com/gZ8al.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gZ8al.png" alt="enter image description here"></a></p>
  
  <p>I am sorry that I am not sure how to calculate the hour equivalent of negative time in row no 3. Might be that's an data issue. </p>