title: Pandas compare next row
body: <p>I have a dataframe like this</p>
  
  <pre><code>d={}
  d['z']=['Q8','Q8','Q7','Q9','Q9']
  d['t']=['10:30','10:31','10:38','10:40','10:41']
  d['qty']=[20,20,9,12,12]
  </code></pre>
  
  <p>I want compare first row with second row</p>
  
  <ol>
  <li>is qty same as next row AND</li>
  <li>is t greater in the next row AND</li>
  <li>is z value same as next row</li>
  </ol>
  
  <p>The desired value is</p>
  
  <pre><code>   qty                   t   z  valid
  0   20 2015-06-05 10:30:00  Q8  False
  1   20 2015-06-05 10:31:00  Q8   True
  2    9 2015-06-05 10:38:00  Q7  False
  3   12 2015-06-05 10:40:00  Q9  False
  4   12 2015-06-05 10:41:00  Q9   True
  </code></pre>