简体   繁体   中英

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

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM