Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/287.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 与srdoc的叶面发行_Python_Python 3.x_Jupyter Notebook_Folium - Fatal编程技术网

Python 与srdoc的叶面发行

Python 与srdoc的叶面发行,python,python-3.x,jupyter-notebook,folium,Python,Python 3.x,Jupyter Notebook,Folium,我正试图根据一个数据框,使用Folium绘制一张地图。在这里你可以检查整个系统。我在下面粘贴有问题的代码片段: map_borough = folium.Map(location = [borough_lat, borough_lng], zoom_start = 10.7) for lat, lng, neighborhood in zip(borough['Latitude'], borough['Longitude'], borough['Neighborhood']): lab

我正试图根据一个数据框,使用Folium绘制一张地图。在这里你可以检查整个系统。我在下面粘贴有问题的代码片段:

map_borough = folium.Map(location = [borough_lat, borough_lng], zoom_start = 10.7)

for lat, lng, neighborhood in zip(borough['Latitude'], borough['Longitude'], borough['Neighborhood']):
    label = folium.Popup(label, parse_html=True)
    folium.CircleMarker(
        [lat, lng],
        radius=5,
        popup=label,
        color='blue',
        fill=True,
        fill_color='#3186cc',
        fill_opacity=0.7).add_to(map_borough)  
map_borough
如笔记本上所示,此代码输出一个奇怪的错误:

---------------------------------------------------------------------------
UndefinedError                            Traceback (most recent call last)
~/miniconda3/lib/python3.7/site-packages/IPython/core/formatters.py in __call__(self, obj)
    343             method = get_real_method(obj, self.print_method)
    344             if method is not None:
--> 345                 return method()
    346             return None
    347         else:

~/miniconda3/lib/python3.7/site-packages/folium/folium.py in _repr_html_(self, **kwargs)
    291             self._parent = None
    292         else:
--> 293             out = self._parent._repr_html_(**kwargs)
    294         return out
    295 

~/miniconda3/lib/python3.7/site-packages/branca/element.py in _repr_html_(self, **kwargs)
    328         # the HTML in the src attribute with a data URI. The alternative of using a srcdoc
    329         # attribute is not supported in Microsoft Internet Explorer and Edge.
--> 330         html = base64.b64encode(self.render(**kwargs).encode('utf8')).decode('utf8')
    331         onload = (
    332             'this.contentDocument.open();'

~/miniconda3/lib/python3.7/site-packages/branca/element.py in render(self, **kwargs)
    319         """Renders the HTML representation of the element."""
    320         for name, child in self._children.items():
--> 321             child.render(**kwargs)
    322         return self._template.render(this=self, kwargs=kwargs)
    323 

~/miniconda3/lib/python3.7/site-packages/folium/folium.py in render(self, **kwargs)
    368             '</style>'), name='map_style')
    369 
--> 370         super(Map, self).render(**kwargs)
    371 
    372     def fit_bounds(self, bounds, padding_top_left=None,

~/miniconda3/lib/python3.7/site-packages/branca/element.py in render(self, **kwargs)
    637 
    638         for name, element in self._children.items():
--> 639             element.render(**kwargs)

~/miniconda3/lib/python3.7/site-packages/branca/element.py in render(self, **kwargs)
    637 
    638         for name, element in self._children.items():
--> 639             element.render(**kwargs)

~/miniconda3/lib/python3.7/site-packages/folium/map.py in render(self, **kwargs)
    367 
    368         figure.script.add_child(Element(
--> 369             self._template.render(this=self, kwargs=kwargs)),
    370             name=self.get_name())
    371 

~/miniconda3/lib/python3.7/site-packages/jinja2/environment.py in render(self, *args, **kwargs)
   1088             return concat(self.root_render_func(self.new_context(vars)))
   1089         except Exception:
-> 1090             self.environment.handle_exception()
   1091 
   1092     def render_async(self, *args, **kwargs):

~/miniconda3/lib/python3.7/site-packages/jinja2/environment.py in handle_exception(self, source)
    830         from .debug import rewrite_traceback_stack
    831 
--> 832         reraise(*rewrite_traceback_stack(source=source))
    833 
    834     def join_path(self, template, parent):

~/miniconda3/lib/python3.7/site-packages/jinja2/_compat.py in reraise(tp, value, tb)
     26     def reraise(tp, value, tb=None):
     27         if value.__traceback__ is not tb:
---> 28             raise value.with_traceback(tb)
     29         raise value
     30 

<template> in top-level template code()

~/miniconda3/lib/python3.7/site-packages/folium/map.py in render(self, **kwargs)
    367 
    368         figure.script.add_child(Element(
--> 369             self._template.render(this=self, kwargs=kwargs)),
    370             name=self.get_name())
    371 

~/miniconda3/lib/python3.7/site-packages/jinja2/environment.py in render(self, *args, **kwargs)
   1088             return concat(self.root_render_func(self.new_context(vars)))
   1089         except Exception:
-> 1090             self.environment.handle_exception()
   1091 
   1092     def render_async(self, *args, **kwargs):

~/miniconda3/lib/python3.7/site-packages/jinja2/environment.py in handle_exception(self, source)
    830         from .debug import rewrite_traceback_stack
    831 
--> 832         reraise(*rewrite_traceback_stack(source=source))
    833 
    834     def join_path(self, template, parent):

~/miniconda3/lib/python3.7/site-packages/jinja2/_compat.py in reraise(tp, value, tb)
     26     def reraise(tp, value, tb=None):
     27         if value.__traceback__ is not tb:
---> 28             raise value.with_traceback(tb)
     29         raise value
     30 

<template> in top-level template code()

UndefinedError: 'None' has no attribute 'replace'
---------------------------------------------------------------------------
未定义错误回溯(最后一次最近调用)
调用中的~/miniconda3/lib/python3.7/site-packages/IPython/core/formatters.py(self,obj)
343方法=获取真实方法(obj,self.print方法)
344如果方法不是无:
-->345返回方法()
346不返回
347其他:
~/miniconda3/lib/python3.7/site-packages/folium/folium.py in_repr_html(self,**kwargs)
291自我.\u父母=无
292其他:
-->293 out=self.\u parent.\u repr\u html.[*kwargs)
294返回
295
~/miniconda3/lib/python3.7/site-packages/branca/element.py in(self,**kwargs)
328#src属性中带有数据URI的HTML。使用srcdoc的替代方法
329#属性在Microsoft Internet Explorer和Edge中不受支持。
-->330 html=base64.b64编码(self.render(**kwargs).encode('utf8')).decode('utf8'))
331空载=(
332“this.contentDocument.open();”
渲染中的~/miniconda3/lib/python3.7/site-packages/branca/element.py(self,**kwargs)
319“呈现元素的HTML表示形式。”“”
320表示名称,子项在self中。\u children.items():
-->321子级渲染(**kwargs)
322返回self.\u template.render(this=self,kwargs=kwargs)
323
渲染中的~/miniconda3/lib/python3.7/site-packages/folium/folium.py(self,**kwargs)
368''),name='map\u style')
369
-->370超级(贴图,自)。渲染(**kwargs)
371
372 def fit_界限(自我、界限、填充_顶部_左侧=无,
渲染中的~/miniconda3/lib/python3.7/site-packages/branca/element.py(self,**kwargs)
637
638表示名称,self.\u children.items()中的元素:
-->639元素。渲染(**kwargs)
渲染中的~/miniconda3/lib/python3.7/site-packages/branca/element.py(self,**kwargs)
637
638表示名称,self.\u children.items()中的元素:
-->639元素。渲染(**kwargs)
渲染中的~/miniconda3/lib/python3.7/site-packages/folium/map.py(self,**kwargs)
367
368图.脚本.添加子元素(元素(
-->369 self._template.render(this=self,kwargs=kwargs)),
370 name=self.get_name())
371
渲染中的~/miniconda3/lib/python3.7/site-packages/jinja2/environment.py(self,*args,**kwargs)
1088返回concat(self.root\u render\u func(self.new\u context(vars)))
1089例外情况除外:
->1090 self.environment.handle_exception()
1091
1092 def呈现异步(self、*args、**kwargs):
句柄中的~/miniconda3/lib/python3.7/site-packages/jinja2/environment.py异常(self,source)
830从.debug导入重写\u回溯\u堆栈
831
-->832重新释放(*重写\回溯\堆栈(源=源))
833
834 def连接路径(自身、模板、父级):
~/miniconda3/lib/python3.7/site-packages/jinja2//\u compat.py重新发布(tp,value,tb)
26 def重新释放(tp,值,tb=无):
27如果值.\uuuu回溯\uuuuu不是tb:
--->28提升值。使用_回溯(tb)
29提高价值
30
在顶级模板代码()中
渲染中的~/miniconda3/lib/python3.7/site-packages/folium/map.py(self,**kwargs)
367
368图.脚本.添加子元素(元素(
-->369 self._template.render(this=self,kwargs=kwargs)),
370 name=self.get_name())
371
渲染中的~/miniconda3/lib/python3.7/site-packages/jinja2/environment.py(self,*args,**kwargs)
1088返回concat(self.root\u render\u func(self.new\u context(vars)))
1089例外情况除外:
->1090 self.environment.handle_exception()
1091
1092 def呈现异步(self、*args、**kwargs):
句柄中的~/miniconda3/lib/python3.7/site-packages/jinja2/environment.py异常(self,source)
830从.debug导入重写\u回溯\u堆栈
831
-->832重新释放(*重写\回溯\堆栈(源=源))
833
834 def连接路径(自身、模板、父级):
~/miniconda3/lib/python3.7/site-packages/jinja2//\u compat.py重新发布(tp,value,tb)
26 def重新释放(tp,值,tb=无):
27如果值.\uuuu回溯\uuuuu不是tb:
--->28提升值。使用_回溯(tb)
29提高价值
30
在顶级模板代码()中
UndefinedError:“None”没有属性“replace”

我在这里和谷歌上都搜索过,但无法找出发生了什么。怎么了?

刚刚找到了错误!我的
for
需要一个
标签
变量在弹出窗口中绘制

map_borough = folium.Map(location = [borough_lat, borough_lng], zoom_start = 10)

for lat, lng, label in zip(borough['Latitude'], borough['Longitude'], borough['Neighborhood']):
    label = folium.Popup(label, parse_html=True)
    folium.CircleMarker(
        [lat, lng],
        radius=5,
        popup=label,
        color='blue',
        fill=True,
        fill_color='#3186cc',
        fill_opacity=0.7).add_to(map_borough)  
map_borough

现在它工作了