Skip to content
Advertisement

Python how to create a new column that measures proximity to a city?

I have a dataframe with Latitude and Longitude columns,

JavaScript

How do I create a column that measures the distance towards a particular location with coordinates (47.631872, -122.217109)

In particular I’d like to use the geodesic function from geopy for the distance: from geopy.distance import geodesic. It takes in the inputs of 2 tuples containing latitudes and longitudes, and outputs the distance.

Advertisement

Answer

Use apply

JavaScript
Advertisement