I have a huge dataframe
. The structure data looks like this:
df
ID Annotation X Y
A Boarding 767513.9918 9425956.2571
A Alighting 767154.1396 9427584.0004
B Boarding 767450.5277 9432627.9543
B Alighting 767495.0101 9426797.1772
C Boarding 767648.9507 9426442.5497
C Alighting 767037.0309 9428878.9032
........
The X and Y data used UTM coordinates. I want to calculate the distance between each ID boarding and alighting. My question is quietly similar but different to this question (Distance matrix in Python Pandas). My expected result looks like this:
result
ID Anotation_1 X_1 Y_1 Anotation_2 X_2 Y_2 Dist
A Boarding 767513.99 9425956.26 Alighting 767154.14 9427584.00 1667.05
B Boarding 767450.53 9432627.95 Alighting 767495.01 9426797.18 5830.95
C Boarding 767648.95 9426442.55 Alighting 767037.03 9428878.90 2512.02
.......
Thank you for your help.