HTTP Error 500 using Python's geopy + Google Maps Geocoding API

903 views Asked by At

So, I'm trying to geocode a column on a Pandas df using Google Maps Geocoding API via geopy and keep getting this as an output:

GeocoderServiceError: HTTP Error 500: Internal Server Error

Yesterday, I used the same code on a slightly smaller df and it worked fine.

import pandas as pd
from geopy import geocoders
df = pd.read_csv('file.csv')

g = geocoders.GoogleV3(api_key="APIKEY")

df["Coordinates"]=df["GEO"].apply(g.geocode, timeout=50)
df["Latitude"]=df["Coordinates"].apply(lambda x: x.latitude if x != None else None)
df["Longitude"]=df["Coordinates"].apply(lambda x: x.longitude if x != None else None)

"Geo" is the column which contains the full addresses.

1

There are 1 answers

0
Raphael Hernandes On

So, it turns out I did not find a way to fix specifically this problem. I had to go around it and handle the errors.

Used this code as an example: https://github.com/woosmap/samples/tree/master/python-samples/batchgeocoding