• Magdalena Konkiewicz

Top 9 Jupyter Notebook extensions

Updated: Feb 5


Image by Syaibatul Hamdi from Pixabay

Introduction

Jupyter Notebook is probably the most popular tool used by Data Scientists. It allows mixing code, text, and inspecting the output in one document.

This is something that is not possible with some other programming IDEs. However, the vanilla version of the Jupyter notebooks is not perfect.

In this article, we will show you how to make it slightly better by installing some useful extensions.



What are Jupyter notebook extensions?

Jupyter notebook extensions are pieces of JavaScript code that run in the background and extend the functionality of the notebook. One extension will be responsible for a particular feature and can be installed or removed as needed.



Enabling extensions

In order to start using extensions, you will need to to install the functionality by running pip commands:



pip install jupyter_contrib_nbextensions
pip install jupyter_nbextensions_configurator
jupyter contrib nbextension install

Now that you have done that you can start Jupyter Notebook and go to the Nbextension tab.



I am now going to share my favorite extensions so make sure you check their boxes and try them out.



Spellchecker

This extension is a spellchecker for the markdown code. It will just highlight the words that are misspelled.




Table of contents

This extension adds a table of content to the notebook. It can be activated and deactivated with the button highlighted in red on the screenshot below.


You can click on any heading within the table of content and you will be taken to the corresponding section with the notebook.

This is a great feature when you are working with notebooks that have a lot of content.



Collapsible headings

This is another extension that helps you navigate through your notebook.

Once you have installed it you will be able to collapse or expand sections below the headings with toggles that appear on the right-hand sides next to the heading text.




Autopep8

This is an extension that helps you format your code according to PEP 8 standards. It will remove empty spaces that are not needed, or add empty lines if required, or apply any other formatting as outlined in PEP8.

In order to install you have to have autopep8 library installed. You can do that by running:



pip install autopep8


Now in order to use it, you need to select cells that need formatting and click on the hammer button from the menu.



As a result, the code from the cell above will look like this after the formatting is applied.


Note that the spaces around the equal sign are removed in a parameter figsize=(15, 10).

Also, the accidental extra space that was present in the for loop just before ‘i’ variable is removed.



ExecuteTime

This extension allows you to time how long it took to run a cell and informs you about the time of the latest execution. The information is displayed below each cell.


This is a very useful feature. Before you rerun the cell you know how long it is going to take.

This will help you to avoid rerunning the cell that takes a very long time to execute if not needed.



Toggle all line numbers

This is a very simple extension that allows you to turn on and off line numbers in code cells using a button in the panel menu.



Variable Inspector

This extension once enabled can be used by selecting a button marked in red in the panel menu (on the screenshot below).

Once you select it, you will be shown the information about all variables that you have in the current namespace. You will be able to see variable names, its types, sizes, shapes, and values.


Hide code

This extension allows you to hide all the code in the notebook so you can focus only on the output.

In order to hide and bring the code back, you can use the eye button in the panel.




Skip-traceback

This extension allows you to skip the traceback when an error in the code is thrown. Instead of the whole traceback, it shows you the error name and short error description.

So this is how the normal error looks like in Jupyter without the extension.



And this is how it looks like with Skip-traceback extension.




It allows you to quickly identify the cause of the error and it is especially useful if the traceback is very long.

It also allows you to expand the traceback and see the whole version if you want.



Summary

I have been using these extensions for a while and some are absolute lifesavers.

Try them out, it really does not take a lot of time to set them up and they will definitively make your notebook more functional and boost your productivity.


Also if you want to learn some more advanced extensions check out this article. It has been written as a follow to the article you are reading right now.


934 views0 comments

Recent Posts

See All