Python 叶肉;序列对象没有属性get\u name

Python 叶肉;序列对象没有属性get\u name,python,folium,Python,Folium,我对folium很陌生,在尝试通过包含坐标对和每个坐标对的位置名称的pandasdf循环向folium地图添加一系列标记时,我遇到了一个AttributeError,例如 location_name location 'foo' [40.736932, -73.997043] 'bar' [40.738859, -73.995058] 'xyz' [40.744085, -74.000394] 使用

我对folium很陌生,在尝试通过包含坐标对和每个坐标对的位置名称的pandas
df
循环向
folium
地图添加一系列标记时,我遇到了一个
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'对象没有属性“get\u name”

我认为这是由
folium
中的
element.py
generic.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(详细信息)我想这就是需要的孩子

此行导致的错误

popup=i.location_name
应该是哪一个

popup = folium.Popup(i.location_name)

如果将多行跟踪也添加回问题,则可能会直接将文件和行暴露在发生异常的堆栈位置。我的猜测是,一些神奇的后台方法/函数希望它的客户端对象提供一个get_name方法来很好地检索文本,然后它可以在一些地图或工具提示弹出窗口中打印为字符串。为什么在df中为i添加
,然后在下一行中尝试向
标记添加完整的列。也许您希望df:folium.Marker(row['location'],popup=row['location\u name'],…)中的行使用类似于
的内容
?您说得对,从我的末尾键入-o-很抱歉造成混淆!我编辑了代码,但现在得到了
TypeError:字符串索引必须是整数