python - Assertion error in Folium - "cannot render this Element if it's not in a Figure" -


trying use folium generate interactive map locations in pandas dataframe. however, when try save map html file, assertion error: "you cannot render element if it's not in figure".

the relevant information i've been able find older forum post closed without enough detail me see how fix it:

https://github.com/python-visualization/folium/issues/495

my code:

data = pd.read_csv(in_file)  route_map = folium.map(location=[data['"poslat"'].mean(), data['"poslon"'].mean()],                        zoom_start=10, tiles='openstreetmap')  lat, lon, date in zip(data['"poslat"'], data['"poslon"'], data['"date"_"time"']):     folium.marker(location=[lat, lon],                   icon=folium.icon(color='blue').add_to(route_map))  out_file = input('enter file name: ') if '.html' not in out_file:     out_file += '.html'  route_map.save(out_file) 

error:

traceback (most recent call last):   file "interactive_map_gen.py", line 21, in <module>     route_map.save(out_file)   file "c:\program files\python36\lib\site-packages\branca\element.py", line 157, in save     html = root.render(**kwargs)   file "c:\program files\python36\lib\site-packages\branca\element.py", line 301, in render     child.render(**kwargs)   file "c:\program files\python36\lib\site-packages\folium\map.py", line 299, in render     super(legacymap, self).render(**kwargs)   file "c:\program files\python36\lib\site-packages\branca\element.py", line 617, in render     element.render(**kwargs)   file "c:\program files\python36\lib\site-packages\branca\element.py", line 598, in render     assert isinstance(figure, figure), ("you cannot render element " assertionerror: cannot render element if it's not in figure. 

the suggested workaround in above forum thread import colormap folium instead of branca, haven't been able find on how that. i've tried re-installing folium, i've tried setting output file name fixed string. i'm @ loss. follows examples folium 0.3.0 @ https://pypi.python.org/pypi/folium. there i'm missing?

i figured out - simple syntax error missed repeatedly.

in loop i'm adding markers, proper syntax

folium.marker(pos, icon).add_to(map)

as have now, i'm trying add icon parameter map, not whole marker.


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -