i have a dataframe:
routeId latitude_value longitude_value
r1 28.210216 22.813209
r2 28.216103 22.496735
r3 28.161786 22.842318
r4 28.093110 22.807081
r5 28.220370 22.503500
r6 28.220370 22.503500
r7 28.220370 22.503500
from this i want to generate a dataframe df2 something like this:
routeId nearest
r1 r3 (for example)
r2 ... similarly for all the routes.
The logic i am trying to implement is
for every route, i should find the euclidean distance of all other routes. and iterating it on routeId.
There is a function for calculating euclidean distance.
dist = math.hypot(x2 - x1, y2 - y1)
But i am confused on how to build a function where i would pass a dataframe, or use .apply()
def get_nearest_route():
.....
return df2