【发布时间】:2021-11-05 14:05:31
【问题描述】:
我正在尝试使用 gps 坐标查找城市 我的数据框看起来像这样
tripId latitude longitude
0 1828765 50.126219 8.767003
1 1828765 50.126173 8.766984
... ... ... ...
497 1828714 53.680520 10.428270
498 1828714 53.680497 10.428355
499 1828714 53.680484 10.428431
我试过这段代码:
import numpy as np
df['location']=np.nan
from geopy.geocoders import Nominatim
geolocator = Nominatim(user_agent="geoapiExercises")
for i in range(df.shape[0]):
df['location'][i] = geolocator.reverse(str(df['latitude'][i])+","+str(df['longitude'][i]))
但它不起作用! init() 缺少 3 个必需的位置参数:“地址”、“点”和“原始” 你们中有人知道如何解决这个问题吗? 谢谢
【问题讨论】:
-
“它不起作用”。解释到底发生了什么
-
@AlexeyLarionov : UFuncTypeError: ufunc 'add' 不包含具有签名匹配类型的循环 (dtype('
dtype(' -
我为经度和纬度添加了 str(),所以现在我有另一个错误:__init__() 缺少 3 个必需的位置参数:'address'、'point' 和 'raw'
-
Documentation 表示可以传递一个元组
(df['latitude'][i], df['longitude'][i]),不一定是字符串!
标签: python data-analysis