title: How do you a apply a function to a cell and the cell below?
body: <p>I am trying to apply a function of two arguments to a cell and the cell below.</p>
  <p>Eg. my function is</p>
  <pre><code>def foo(x,y):
      return f'{x} -&gt; {y}'
  </code></pre>
  <pre><code># Input
  s = pd.Series([1,2,3])
  
  # Output
  pd.Series(['1 -&gt; 2', '2 -&gt; 3', '3 -&gt; nan'])
  </code></pre>
  <p>I'm not sure what command I could use to do this in pandas.</p>
  <p>Notes:</p>
  <ol>
  <li><p>If I were subtracting the values I could do <code>s.diff(1)</code></p>
  </li>
  <li><p>If this were a vectorizable operation I could do <code>foo(s, s.shift(-1))</code></p>
  </li>
  <li><p>I am looking for a functional style ideally (ie. avoiding an explicit loop) - just a style preference.</p>
  </li>
  <li><p>The function <code>foo</code> above is illustrative, I'm looking for something that works for any arbitrary function of two arguments (in my usecase I'm trying to compute text similarity using a function <code>foo(text1:str, text2:str)-&gt;float</code>)</p>
  </li>
  </ol>