我创建了一个pandas数据框架,如下所示:
df = pd.read_csv("List-of-museums.csv", header='infer', sep=",")
from geopy import geocoders
df2 = df['Name'] #there are multiple museums in the column 'Name'. I would like to get their coordinates
df2 = df2.tolist()
coordinates = []
for museum in df2:
g = geocoder.google(museum)
coordinates.append(g.latlng)
comb = dict(zip(df2,coordinates))
comb = pd.Series(comb, name='Coordinates')
comb = comb.to_frame()
Coordinates
18 Stafford Terrace [51.500476, -0.1968857]
2 Willow Road []
575 Wandsworth Road []
7 Hammersmith Terrace []
Anaesthesia Heritage Centre []
Apsley House [51.5034719, -0.1516708],[41.5034719,-0.1516708]
期望输出:
^{pr2}$因此,我们添加了最后一列,显示是否找到了坐标,如果找到了,有多少。在
我认为你需要:
另一个解决方案是:
^{pr2}$相关问题 更多 >
编程相关推荐