How to Create HTML and PDF Files from Jupyter Notebooks

Converting to HTML

You can convert the notebook named test.ipynb to HTML using the following command:

jupyter nbconvert --execute --to html test.ipynb

Converting to PDF

You can convert the notebook named test.ipynb to PDF using the following command:

jupyter nbconvert --execute --to pdf test.ipynb

If you get an error saying “Please check that pandoc is installed”, you’ll need to install it by:

pip install pandoc

Hiding the Code

If you only want to present the markdown cells and the output without displaying your code, you can pass --no-input to nbconvert:

jupyter nbconvert --execute --to html test.ipynb --no-input

Hiding the Indexes from Pandas Dataframe Output Tables

When printing the data frame, just add .style.hide_index() to the end of the data frame object.

Further Reference

  1. https://medium.com/p/a9440f6045c6