Skip to content
Advertisement

Longitude and Latitude Distance Calculation between 2 dataframes

I have the following two dataframes. Call this df1

JavaScript

and call this one df2

JavaScript

I want to know how I can calculate the distance between place and all cities listed. So it should look something like this.

JavaScript

I’m reading through this particular post and attempting to adapt:Pandas Latitude-Longitude to distance between successive rows

JavaScript

Advertisement

Answer

The following code worked for me:

JavaScript

Note that this calculates the miles between each location as direct shots there. Doesn’t factor in twists and turns.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement