title: How do I calculate the distance between a row and the row immediately before it for each different value of a third column?
body: <p>I have a dataframe with devices, dates, and lat/lon columns like this:</p>
  <pre><code>e5c0e3a5    2019-09-23 00:25:48 -44.132 -30.369
  e5c0e3a5    2019-09-23 00:30:48 -43.437 -30.633
  ...
  a5c0d8b8    2019-09-23 03:20:48 -30.132 -40.369
  a5c0d8b8    2019-09-23 03:50:12 -30.437 -41.633
  </code></pre>
  <p>the records are sorted by user and by time. I need to measure the distance travelled by each user at time t, and time t+1 (or, to avoid the first nan, t and t-1, starting at row 2).</p>
  <p>I'm using the <code>from geopy.distance import geodesic</code> function to calculate the distance, and would like resulting dataframe of the style:</p>
  <pre><code>e5c0e3a5    2019-09-23 00:25:48 20
  a5c0d8b8    2019-09-23 03:50:12 50
  ...
  </code></pre>
  <p>where I calculated the distance in kms to be 20 by taking row 2 and measuring the distance wrt row 1.</p>
  <p>In more general terms, how do I carry out an operation (<code>geodesic</code>) for each different device between a row and the row immediately before it?</p>