I am trying to use 2 different dataframes each with a different set of lat/long coordinates to calculate the distance between them using Geopy.
from geopy import distance
def dist_calc (row):
start = (row['Lat_1' ], row['Long_1'])
stop = (row['Lat_2'], row['Long_2'])
return distance.great_circle(start, stop).km
df['distance'] = df.apply (lambda row: dist_calc (row), axis=1)
I keep getting the below error. I have tried with , ignore_index=True as well.
KeyError: ('Lat_2', 'occurred at index 0')
Do I need to do merge or concatenate my dataframes to complete this operation? Or how do I make this code work?