title: Apply function on pairs of rows in Pandas dataframe
body: <p>I'm a newbie to pandas dataframe, and I wanted to apply a function taking couple of rows in the same column. Like when you apply the function diff(), but i want to calculate the distance between text. so i defined a function which measure the distance, and i tried to use apply but i don't know how can i pick couple of rows. Below i show an example that i'have tried to do and what i expected:</p>
  
  <pre><code>def my_measure_function(x,y):
     return some_distance_calculus(x,y)
  
  &gt;&gt;&gt; from pandas import DataFrame
  &gt;&gt;&gt; df = DataFrame({"text": ['hello','hella','hel'], "B": [3,4,4]})
  &gt;&gt;&gt; df['dist'] = df.apply(lambda x, y: my_measure_function(x, y), axis=0)
  </code></pre>
  
  <p>but it doesn't work.
  What i want to obtain is:</p>
  
  <pre><code>&gt;&gt;&gt; df
        text  B  dist
  0    hello  3    0
  1    hella  4    1
  2    hel    4    2
  </code></pre>
  
  <p>Thanks in advance for any help that you can provide me.</p>