title: How to find the difference between each subsequent pair of DataFrame.index values in pandas?
body: <p>I have created a <code>DataFrame</code> in order to process some data, and I want to find the difference in time between each pair of data in the <code>DataFrame</code>. Prior to using pandas, I was using two numpy arrays, one describing the data and the other describing time (an array of <code>datetime.datetime</code>s). With the data in arrays, I could do <code>timearray[1:] - timearray[:-1]</code> which resulted in an array (of n-1 elements) describing the gap in time between each pair of data.</p>
  
  <p>In pandas, doing <code>DataFrame.index[1] - DataFrame.index[0]</code> gives me the result I want – the difference in time between the two indices I've picked out. However, doing <code>DataFrame.index[1:] - DataFrame.index[:-1]</code> does not yield an array of similar results, instead simply being equal to <code>DataFrame.index[-1]</code>. Why is this, and how can I replicate the numpy behaviour in pandas?</p>
  
  <p>Alternatively, what is the best way to find datagaps in a <code>DataFrame</code> in pandas?</p>