How to match scipy.spatial.distance results back to pandas df

Vincent Davis vincent at vincentdavis.net
Thu Jul 16 12:46:41 EDT 2020


I am trying to find points in the activity that are near points in segment.
I get the results from distance() and what to identify the points in
segment and activity that are within some value of each other .0001 for
example.
One idea I had was to append each array row (or column) to the
corresponding row in the df after converting it to a dict so that I can
lookup the point in the other df.

Any suggestions, ideas?

from scipy.spatial import distance
a = distance.cdist(segment[['Latitude', 'Longitude']],
activity[['Latitude', 'Longitude']], 'euclidean')
b = a[a < .0001]
b

array([8.83911760e-05, 6.31347765e-05, 3.89486842e-05, 2.13775583e-05,
       2.10950231e-05, 4.10487515e-05, 6.70000000e-05, 9.10878697e-05,
       7.61183289e-05, 9.90050504e-05, 7.88162420e-05, 5.90931468e-05,
       4.50111097e-05, 4.97393205e-05, 6.78969808e-05, 8.52115016e-05,
...


Thanks
Vincent Davis
720-301-3003
*Want to get a hold of me?*


*SMS: awesome.phone: ok...*
*email: bad!*


More information about the Python-list mailing list