A few things picked up as I begin to learn how to do my data wrangling using Jupyter notebooks.
Creating a Table of Contents
If you're tired of scrolling up and down a Jupyter notebook, creating a table of contents might be the solution. Perhaps the simplest way to do this is with the Jupyter nbextension project.
Here are the steps to take to get yourself started.
Install jupyter_contrib_nbextensions.
- I used my IDE, PyCharm, to install the package. If you prefer to use pip, follow the nbextension documentation.
Activate your virtual environment. Run these commands to enable nbextensions.
(venv) $ jupyter contrib nbextension install --user (venv) $ jupyter nbextensions_configurator enable --user
Start Jupyter.
- You should see the new Nbextensions tab next to the Clusters tab, as in the screenshot below.
Open the Nbextensions tab. Select Table of Contents (2).
- The screenshot below hints at the many other Jupyter notebook extensions now available to you.
Converting to HTML
Here's how you convert a notebook in your present working directory to HTML. (Note that you will probably first have to activate your virtual environment.)
(venv) $ jupyter nbconvert TokensLemmasStopwords.ipynb --to=html [NbConvertApp] Converting notebook TokensLemmasStopwords.ipynb to html [NbConvertApp] Writing 652273 bytes to TokensLemmasStopwords.html (venv) $
To convert a notebook that has a table of contents:
(venv) $ jupyter nbconvert TokensLemmasStopwords.ipynb --to=html_toc [NbConvertApp] Converting notebook TokensLemmasStopwords.ipynb to html_toc [NbConvertApp] Writing 653494 bytes to TokensLemmasStopwords.html (venv) $
Note that if your notebook has matplotlib
and perhaps other visualizations, these will be reproduced in a directory of .png objects.
External Links
Table of Contents (2) provides some details on the table of contents options.
Parul Pandey's Towards Data Science post is a nice introduction to some of the other extensions you might want to explore.