Я недавно использовал python, и я делаю работу, используя Foursquare и данные, полученные из Википедии. Я пытаюсь создать карту со следующим кодом:
venues_map = folium.Map(location=[latitude, longitude], zoom_start=13) # generate map centred of Ciutat Vella
# add a red circle marker to represent the center of the neighborhoods
folium.vector_layers.CircleMarker(
['lat','lng'],
radius=10,
color='red',
popup='Eixample',
fill = True,
fill_color = 'red',
fill_opacity = 0.6
).add_to(venues_map)
# add the shops as blue circle markers
for lat, lng, label in zip(new_df.lat, new_df.lng, new_df.categories):
folium.vector_layers.CircleMarker(
[lat,lng],
radius=5,
color='blue',
popup=label,
fill = True,
fill_color='blue',
fill_opacity=0.6
).add_to(venues_map)
# display map
venues_map
При выполнении строки я получаю следующую ошибку:
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
/opt/conda/envs/Python36/lib/python3.6/site-packages/folium/utilities.py in validate_location(location)
58 try:
---> 59 float(coord)
60 except (TypeError, ValueError):
ValueError: could not convert string to float: 'lat'
During handling of the above exception, another exception occurred:
ValueError Traceback (most recent call last)
<ipython-input-27-7a61c4e1c46b> in <module>
11 fill = True,
12 fill_color = 'red',
---> 13 fill_opacity = 0.6
14 ).add_to(venues_map)
15
/opt/conda/envs/Python36/lib/python3.6/site-packages/folium/vector_layers.py in __init__(self, location, radius, popup, tooltip, **kwargs)
303 def __init__(self, location, radius=10, popup=None, tooltip=None, **kwargs):
304 super(CircleMarker, self).__init__(location, popup=popup,
--> 305 tooltip=tooltip)
306 self._name = 'CircleMarker'
307 self.options = path_options(line=False, radius=radius, **kwargs)
/opt/conda/envs/Python36/lib/python3.6/site-packages/folium/map.py in __init__(self, location, popup, tooltip, icon, draggable, **kwargs)
275 super(Marker, self).__init__()
276 self._name = 'Marker'
--> 277 self.location = validate_location(location)
278 self.options = parse_options(
279 draggable=draggable or None,
/opt/conda/envs/Python36/lib/python3.6/site-packages/folium/utilities.py in validate_location(location)
61 raise ValueError('Location should consist of two numerical values, '
62 'but {!r} of type {} is not convertible to float.'
---> 63 .format(coord, type(coord)))
64 if math.isnan(float(coord)):
65 raise ValueError('Location values cannot contain NaNs.')
ValueError: Location should consist of two numerical values, but 'lat' of type <class 'str'> is not convertible to float.
Я посмотрел и столбец LAT, если это поплавок, я не знаю, как это исправить, и я не могу двигаться вперед. Я был бы признателен за любую помощь.
Значение Lat исходит из следующей таблицы, в которой оно показывает название окрестностей Барселоны и показывает его широту и долготу, чтобы можно было взять оттуда значения для формирования карта:
введите описание изображения здесь