0
votes

I have two locations with longitude and latitude given and I would like to get the distance between these points in python. My data set looks like below:

df_TEST = pd.DataFrame({'Location': ['X'],
                     'Long': [ 28.63615701706],
                     'Lat': [ 41.0693487044612],
                     'Location1': ['Y'],
                     'Long1': [30.7158891385255],
                     'Lat1': [36.963486025471]})  

My solution as suggested Getting distance between two points based on latitude/longitude

 df_TEST['distance']=geopy.distance.geodesic(( df_TEST['Long'], 
 df_TEST['Lat']),(df_TEST['Long1'], df_TEST['Lat1'])).km

My error below please let me know how to fix this. Thank you.

ValueError: The truth value of a Series is ambiguous. Use a.empty, 
a.bool(), a.item(), a.any() or a.all().
1

1 Answers

1
votes

As seen in the Documentation it accepts float tuple and not a pandas series tuple that you are trying to do here, try this instead:

df_TEST['distance']=geopy.distance.geodesic(( float(df_TEST['Long']), 
 float(df_TEST['Lat'])),(float(df_TEST['Long1']), float(df_TEST['Lat1']))).km