I am a newbie in python, but I like to process data in pandas.
I have a hundred pairs of CSV data such as passenger and bus stop data. The passenger structure data is Person, and XY coordinates (UTM-Meter). The bus stop data structure is the bus stop name (BS), and XY coordinates (UTM-Meter. My data looks like this:
df(person)
Person X Y
A_first 260357.3199 4064458.685
A_last 261618.5243 4064789.928
B_first 258270.5926 4063717.789
B_last 258270.5926 4063717.789
C_first 259051.758 4064462.021
C_last 258270.5926 4063717.789
D_first 260764.3916 4064624.977
D_last 260753.9053 4064569.745
E_first 258270.5926 4063717.789
E_last 258270.5926 4063717.789
F_first 258262.2825 4063740.234
F_last 258270.5926 4063717.789
G_first 258326.2393 4064104.899
G_last 258270.5926 4063717.789
H_first 259491.5911 4064838.328
H_last 260747.1408 4064647.669
and,
df(bus stop)
BS X Y
BS1 258280.8228 4063715.835
BS2 259961.3734 4064840.298
BS3 260360.0219 4064468.593
BS4 260530.5126 4064683.101
BS5 260806.7009 4064399.184
BS6 261178.4165 4063605.91
BS7 261222.1745 4064495.158
BS8 261627.6173 4064281.38
BS9 261662.8833 4064793.444
I want to analyze the distance matrix
between person and bus stop data. My desire output is InputID (Person), TargetID (bus stop) and distance. Distance is the distance between person point data and bus stop point data. My expected result:
result
InputID (Person) TargetID (BS) Distance (meter)
A_first BS1 xx
A_first BS2 xx
A_first BS3 xx
A_first BS4 xx
A_first BS5 xx
A_first BS6 xx
A_first BS7 xx
A_first BS8 xx
A_first BS9 xx
A_last BS1 xx
A_last BS2 xx
A_last BS3 xx
A_last BS4 xx
A_last BS5 xx
A_last BS6 xx
A_last BS7 xx
A_last BS8 xx
A_last BS9 xx
............. so on
Any advice for me? thank you