Has anyone encountered the following problem? I have a pandas DataFrame containing the coordinates of renewable energy installations and I tried using reverse geocoding to get the related address data. I used geopy for this. The code worked fine on a test sample I used, but when I try to apply it to the complete data it throws and error where it says TypeError: 'address' must not be None.
So I have a pandas DataFrame called xml_data with a 'coordinates' column in which coordinates are put in the form of e.g.: 52.06192, 4.53075
The code is:
import pandas as pd
import geopy
from geopy.geocoders import Nominatim
from geopy.extra.rate_limiter import RateLimiter
import tqdm
#Create an extra column in the xml data to put the coordinates in as 'lat,lon'
xml_data['coordinates'] = xml_data['lat'].map(str) + ',' + xml_data['lon'].map(str)
#Create service provicder and pass timeout to be 10 minutes to prevent timeout errors
locator = Nominatim(user_agent='myGeocoder', timeout=10)
rgeocode = RateLimiter(locator.reverse, min_delay_seconds=0.001)
#Use the reverse code. Add tqdm to monitor progress.
tqdm.tqdm.pandas(desc="progress-bar")
xml_data['address'] = xml_data['coordinates'].progress_apply(rgeocode)
If the address for a specific coordinate doesn't exist, I thought, based on the docs, that a None value would be returned and not an error. Any thoughts on what is likely to be the issue?
ps: Apologies if my question wasn't formulated clearly enough, if there is anything I should add please let me know.