问题描述
我正在尝试从地址列表中获取纬度和经度坐标列表。我的地理定位 API 工作得很好。
我正在使用我作为地址加载的文件 address.csv,然后添加了两个空白列 'lat' 和 'long',以便addresses.head() 返回
当我尝试运行以下 for 循环时
for x in range(len(addresses)):
try:
time.sleep(1) #to add delay in case of large DFs
geocode_result = gmaps.geocode(addresses['Full_Address'][x])
addresses['lat'][x] = geocode_result[0]['geometry']['location'] ['lat']
addresses['long'][x] = geocode_result[0]['geometry']['location']['lng']
except IndexError:
print("Address was wrong...")
except Exception as e:
print("Unexpected error occurred.",e )
addresses.head()
我明白了 地址错了... 地址错误...
但是,如果我单独运行每个地址
geocode_result = gmaps.geocode('3220 Latrobe Dr.,Charlotte,NC,28211')
print("geocode result",geocode_result[0]["geometry"]["location"])
我得到了正确的输出 地理编码结果 {'lat': 35.1989906,'lng': -80.8036266}
我做错了什么?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)