I have an data frame like this
ID | priority | latitude | longitude
412 | 1 | 36.67495 | 34.36598056
412 | 2 | 39.88226389 | 44.04348611
412 | 3 | 39.94746667 | 31.35788230
764 | 1 | 39.94746667 | 44.07428056
764 | 2 | 39.88226389 | 43.98109444
764 | 3 | 36.67495 | 32.46473056
What i want to do here, for each ID , i want to average calculate distance from 1st priority to 2nd and 3rd.
Example for 412 ID
I have a function which is calculates distance between 2 point.
km = distance_calc(lat1,lon1,latx,lonx)
distance_calc(36.67495,34.36598056,39.88226389,44.04348611)
distance_calc(36.67495,34.36598056,39.94746667,31.35788230)
This operation will repeat for each IDs and i will take average for all distances. I solved this problem with dataframe row iteration but this method is very very slow.