title: I cannot create new column in my data series in python for an assignment on the haversine formula
body: <p>I am trying to create a new column to manipulate the data set:</p>
  <pre><code>df['longitude'] = df['longitude'].astype(float)
  df['latitude'] = df['latitude'].astype(float)
  </code></pre>
  <p>then ran the function for haversine:
  from math import radians, cos, sin, asin, sqrt</p>
  <pre><code>def haversine(lon1,lat1,lat2,lon2):
      &quot;&quot;&quot;
      Calculate the great circle distance between two points 
      on the earth (specified in decimal degrees)
      &quot;&quot;&quot;
      # convert decimal degrees to radians 
      lon1, lat1, lon2, lat2 = map(radians, [lon1, lat1, lon2, lat2])
      # haversine formula 
      dlon = lon2 - lon1 
      dlat = lat2 - lat1 
      a = sin(dlat/2)**2 + cos(lat1) * cos(lat2) * sin(dlon/2)**2
      c = 2 * asin(sqrt(a)) 
      km = 6367 * c
      return km
  </code></pre>
  <p>But when I run this code :</p>
  <pre><code>df['d_centre']=haversine(lon1,
                           lat1,
                           df.longitude.astype(float),
                           df.latitude.astype(float))
  </code></pre>
  <p>to create a new column in my df I get this error:</p>
  <pre><code>Error: cannot convert the series to &lt;class 'float'&gt;
  </code></pre>
  <p>I tried this as well:</p>
  <pre><code>df['d_centre']= haversine(lon1,lat1,lat2,lon2)
  </code></pre>
  <p>the haversine is working but when I try to create the new column in my df, I get this error. I have tried converting to a list as well but I'm getting the same result</p>