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': ['X1','X2'],
'Long': [ 28.63615701706,76],
'Lat': [ 41.0693487044612,54],
'Location1': ['Y1','Y2'],
'Long1': [30.7158891385255,65],
'Lat1': [36.963486025471,45]})
I would like to add a new column to this dataframe with below code but it works only for one row. I have a huge data set and I would like to add this column without do loop. Solution suggested from How to find the distance between two points given longitude and latitude in python-error? How can I do this?
df_TEST['distance']=geopy.distance.geodesic(float(df_TEST['Long'] .
[0]), float(df_TEST['Lat'][0]),(float(df_TEST['Long1'] .
[0]),float(df_TEST['Lat1'][0]))).km