what I have?
I got the following df:
id latitude longitude
0 0 31.23333 34.78333
1 1 nan nan
2 2 42.70704 -71.16311
.
.
.
what I what to do?
I want to add a column with the country name if the lat/long aren't nan:
id latitude longitude country
0 0 31.23333 34.78333 Israel
1 1 nan nan
2 2 42.70704 -71.16311 USA
.
.
.
what I have tried?
df['country'] = ''
for index, row in df.iterrows():
print((row['latitude'], row['longitude']))
if math.isnan(row['latitude']) or math.isnan(row['longitude']):
continue
else:
geolocator = Nominatim(user_agent="row_{}".format(index))
location = geolocator.reverse((row['latitude'], row['longitude']))
row['country'] = location.raw['address']['country']
what is the problem?
I am getting the following error:
requests.exceptions.SSLError: HTTPSConnectionPool(host='nominatim.openstreetmap.org', port=443): Max retries exceeded with url: /reverse?lat=31.23333&lon=34.78333&format=json&addressdetails=1 (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1123)')))
how can I solve this problem?