大叶& Series对象没有属性get_name

时间:2016-06-07 10:50:44

标签: python folium

我对folium很新,在尝试通过循环包含坐标对的pandas AttributeErrorfolium地图时,面对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' 文件引起的:

{{1}}

感谢任何有关如何解决这个问题的帮助!

1 个答案:

答案 0 :(得分:1)

迟到总比不到好!到达同一错误代码后到达这里,我忘了打电话给folium.Popup(details)我想这是需要的孩子。

此行引起的错误

popup=i.location_name

应该是

popup = folium.Popup(i.location_name)