title: How to calculate the distance between latitudes and longitudes of two stations in a pandas dataframe
body: <p>I am having a dataframe with station info including latitudes and longitudes as follows:</p>
  <pre><code>start_lat   start_lng   end_lat      end_lng
  41.877726   -87.654787  41.888716   -87.644448
  41.930000   -87.700000  41.910000   -87.700000
  41.910000   -87.690000  41.930000   -87.700000  
  </code></pre>
  <p>and like wise.</p>
  <p>I want to create a distance column from these info where the distance can be either in km or in miles for distance between these start and end points.</p>
  <p>(As shared in the kin below, when I try to implement the SO answer, I encounter an error.)</p>
  <pre><code>from math import sin, cos, sqrt, atan2
  dlon = data.end_lng - data.start_lng
  dlat = data.end_lat - data.start_lat
  
  a = ((sin(dlat/2))**2 + cos(lat1) * cos(lat2) * (sin(dlon/2))**2)
  c = 2 * atan2(sqrt(a), sqrt(1-a))
  data['distance'] = R * c
  </code></pre>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>TypeError                                 Traceback (most recent call last)
  &lt;ipython-input-8-a8f8b698a81b&gt; in &lt;module&gt;()
        2 dlon = data.end_lng - data.start_lng
        3 dlat = data.end_lat - data.start_lat
  ----&gt; 4 a = ((sin(dlat/2))**2 + cos(lat1) * cos(lat2) * (sin(dlon/2))**2).apply(lambda x: float(x))
        5 c = 2 * atan2(sqrt(a), sqrt(1-a))
        6 data['distance'] = R * c
  
  /usr/local/lib/python3.7/dist-packages/pandas/core/series.py in wrapper(self)
      127         if len(self) == 1:
      128             return converter(self.iloc[0])
  --&gt; 129         raise TypeError(f"cannot convert the series to {converter}")
      130 
      131     wrapper.__name__ = f"__{converter.__name__}__"
  
  TypeError: cannot convert the series to &lt;class 'float'&gt;</code></pre>
  </div>
  </div>
  </p>
  <p>How to resolve this?</p>