Rendering Juypter Notebooks

I am using nbconvert to render out a jupyter notebook and want to try and show case an interactive dataframe so that other members of my team can look at the data, but there are more markdown cells and plots that come after this. However for some reason after I use a

show(df)

in a cell it causes the following problem.

I am able to use show(df) like that by:

from itables import init_notebook_mode, show
init_notebook_mode(all_interactive=False)

Problem image:

I do not know if I need to edit the template for fixing this. I have edited the classic built in template to not show any of the code since this is a report kind of document that is being shown to non technical people, and the code does not need to be shown.

To do this this was added to the index.html.j2 file:

{% block input_group -%}
{% endblock input_group %}

{% block in_prompt -%}
{%- endblock in_prompt %}

{% block empty_in_prompt -%}
{%- endblock empty_in_prompt %}

{% block output_prompt %}
{% endblock output_prompt %}

{% block input %}
{%- endblock input %}

{% block output_area_prompt %}
{% endblock output_area_prompt %}

the actual command line prompt to run the conversion is:

jupyter nbconvert --to html "$notebook" --template=classicNoCode --execute

For HTML exports i can really recommend using the prettyjupyter template.

pip install pretty-jupyter
jupyter nbconvert --to html --template=pj mynotebook.ipynb

I created a metadata editor extension for it which you can find here.

pip install pretty_jupyter_metadata_form

You can use the metadata editor from the property inspector on the right hand side of jupyterlab to style each cell behaviour individually (hide the code, hide the output, hide it altogether, code folded or not). You can also configure if you want a TOC and how it fills it self up, default code folding behaviour, a lot of different themes to select from and if you use plotly you can add the js it to the html export so it works offline.

2 Likes