我对 folium 很陌生,并且试图通过循环遍历包含坐标对和每对位置名称的熊猫AttributeError
来向地图添加一系列标记,例如folium
df
location_name location
'foo' [40.736932, -73.997043]
'bar' [40.738859, -73.995058]
'xyz' [40.744085, -74.000394]
使用以下代码:
center_map = [40.738859, -73.995058]
map_1 = folium.Map(location=center_map, tiles=None, zoom_start=12)
for i in df:
folium.Marker(i.location,
popup=i.location_name,
icon=folium.Icon(color='purple')
).add_to(map_1)
但是,我收到以下错误:
AttributeError: 'Series' object has no attribute 'get_name'
我认为是由element.py
和generic.py
文件引起的folium
:
/Users/martin/anaconda/envs/py3k/lib/python3.5/site-packages/folium/element.py in add_children(self, child, name, index)
85 def add_children(self, child, name=None, index=None):
86 """Add a child."""
---> 87 return self.add_child(child, name=name, index=index)
88
89 def add_child(self, child, name=None, index=None):
/Users/martin/anaconda/envs/py3k/lib/python3.5/site-packages/folium/element.py in add_child(self, child, name, index)
90 """Add a child."""
91 if name is None:
---> 92 name = child.get_name()
93 if index is None:
94 self._children[name] = child
/Users/martin/anaconda/envs/py3k/lib/python3.5/site-packages/pandas/core/generic.py in __getattr__(self, name)
2667 if name in self._info_axis:
2668 return self[name]
-> 2669 return object.__getattribute__(self, name)
2670
2671 def __setattr__(self, name, value):
AttributeError: 'Series' object has no attribute 'get_name'
感谢有关如何解决此问题的任何帮助!