jupyter / jupyter/notebook

html does not appear in jupyter

Open
#4,153 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Jupyter Notebook
Stars
13.3k
Forks
5.8k
Avg merge
6d 11h
Merged PRs (30d)
7

Description

I use the following code

import folium
 import pandas as pd
 
 df = pd.read_csv('meteo.csv', encoding='cp1251', sep =';')
 customers = zip(df['lat'], df['lng'])
 m = folium.Map(location=[70, 100], zoom_start=1)
 folium.Marker(location=customers[0]).add_to(m)
 folium.Marker(location=customers[1]).add_to(m)
 folium.Marker(location=customers[3]).add_to(m)
 
 m

if markers are 2, then the folium displays a map with markers, but if markers are 3 or or more, then I see an empty window in jupyter, there are no errors. How to fix it?

The case is most likely in Jupiter.
If I run the code:

    def embed_map(m):
        from IPython.display import HTML
    
        m.save('index.html')
        with open('index.html') as f:
            html = f.read()
    
        iframe = '<iframe srcdoc="{srcdoc}" style="width: 100%; height: 750px; border: none"></iframe>'
        srcdoc = html.replace('"', '&quot;')
        return HTML(iframe.format(srcdoc=srcdoc))
    
    
    embed_map(m)

I get the correct html, but it also does not appear in jupyter.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the supplied folium and pandas example in Jupyter Notebook, first with two markers and then with three or more. Compare the rendered notebook output with the generated index.html and the iframe returned by embed_map. Done means maps with three or more markers render correctly without an empty output or errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
jupyter-notebook, python
Domain
frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.