Folium & Series 对象没有属性 get_name

Folium & Series object has not attribute get_name

我是 folium 的新手,在尝试通过遍历 pandas dffolium 地图添加一系列标记时遇到 AttributeError包含坐标对和每对的位置名称,例如

   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'

我认为是由 folium 中的 element.pygeneric.py 文件引起的:

/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'

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

迟到总比不到好!在相同的错误代码之后到达这里,我忘记调用 folium.Popup(details) 我想这就是需要的 child。

此行造成的错误

popup=i.location_name

应该是

popup = folium.Popup(i.location_name)