Traversing Data
Follow step-by-step instructions to calculate the distance between all locations with OpenStreetMap.
We'll cover the following
We calculated the distances between two places. However, we need to calculate the distances between all locations to be able to calculate the shortest total distance. Since we don’t want to repeat the previous step manually for all locations, we’ll solve it via a loop instead.
Distance between all locations
To get started, let’s first calculate the distance between three stores: A, B, and C. With islice
, we iterate over the df.iterrows()
iterable, which starts at counterFixed
. Using df.index
!= i
, we ensure that the distance from any store to itself is not calculated.
Get hands-on with 1400+ tech skills courses.