How to add the name of the nearest point?

I have two data frames with coordinates of attractions and exists. import pandas as pd import geopy from geopy.distance import geodesic attr = pd.DataFrame( {‘attraction’:[‘circuit’, ‘roller …

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

I have a dataframe with Latitude and Longitude columns, 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. Answer Use apply

geopy wont return proper coordinates for canadian postal codes

I am trying to convert Canadian Postal codes into lat, long coordinates however geopy returns them as either none or somewhere in a different country Output AttributeError: ‘NoneType’ object has no attribute ‘latitude’ OR some random address Answer I think the problem here is either the API you use for geopy does not support for CA zip code, or you don’t set ‘CA’ as the country option. So when the geocode can’t retrieve the info from the input, it returns None. To achieve the same goal, I would prefer use pgeocode library.