Jupyter Notebook Extensions You Didn’t Know You Needed

Jupyter notebook is a very powerful tool to do EDA analysis, present findings and share code. Over time, I came to know of a few extensions (plugins) that changed that were not present in the original Jupyter notebook. However, implementing these add-ons changed the look and feel of Jupyter notebook and it has been more fun to work on.

Table of Contents

  1. Dark Mode Theme
  2. Nbextensions Package
  3. Widget Extension

1. Themes (Dark Mode) Extension

What if I tell you there are more to Jupyter than white background notebook. So if are bored with the custom theme, you are in luck. From YouTube to Instagram, the dark theme can be found everywhere. So this add-on is also available in the notebook with many more.

  • Whenever you change the theme, the notebook needs to be reloaded.
  • Below commands can either be run on Anaconda Prompt or within the Jupyter Notebook by placing ‘!’ before the command.

Let’s start with the installation

pip install jupyterthemes

List of available themes

jt -l

Install the dark theme with

jt -t chesterish

Restore the original theme any time using

jt -r  
Chesterish Theme (Dark Theme)
Chesterish Theme

Click here to find the Jupyterthemes GitHub repository.

2. Nbextensions

Extend the notebook experience by using one of the most popular extension package Nbextensions which is a bundle of useful plugins.

You can install Nbextensions from Jupyter notebook using

conda install -c conda-forge jupyter_contrib_nbextensions
conda install -c conda-forge jupyter_nbextensions_configurator 

Once they’re installed, you’ll see a nbextensions tab. Explore away!

After the installation of Nbextensions go to the home page of your jupyter notebook, and you will find a new NBExtensions tab.

Nbextensions

Just click on the extension of your choice to enable it. For further information on extension scroll down after selecting the extension.

Scroll down selected Nbextensions extension for its description

Popular extensions

1. Execute Time

ExecuteTime extension displays the time when each cell has been executed and how long it took.

Execute Time

2. Hinterland —

This enables code autocompletion menu for every keypress in a code cell, instead of calling it with tab.

Hinterland autocomplete

3. Snippets Extension has 2 popular use cases:

3(a). Snippets Menu Adds a drop-down menu to the Notebook toolbar that allows easy insertion of basic code snippet cells into the current notebook.

Snippets Menu Extension

3(b). Snippets As the name suggests you can create snippets of codes that you reuse a lot.

Whenever I open a new Jupyter notebook, I used to copy-paste a lot of libraries and use the custom settings for some of them. Well not anymore.

Pandas, numpy, matplotlib are some of the typical libraries that are always used. So to automate this, Snippets plugin comes to rescue.

Snippets extension adds a drop-down menu to the Notebook toolbar that allows easy insertion of code snippets into the notebook cells.

To add a new snippet that imports numpy, matplotlib, and other libraries, the snippets.json file needs to be modified. The file can be found at C:\Users\..\AppData\Local\Continuum\anaconda3\share\jupyter\nbextensions\snippets location. This path may vary for your system. Or you can simply search for snippets.json on your system. Make the following changes to the JSON file.

Now, the changes will be reflecting in the Snippet extension.

Snippets Extension

Nbextensions is open-source and tons of extensions have been developed for Jupyter Notebooks. You can find the extension list here

3. Widget Extensions

Widgets are eventful python objects that have a representation in the browser, often as a control like a slider, textbox, etc. Widgets can be used to build interactive GUIs for the notebooks.

Let’s start with the installation

pip install ipywidgets
jupyter nbextension enable --py widgetsnbextension

The ipywidgets library has an interact function that creates interactive user interface (UI) controls for exploring data.

1. Slider Widget

Pass this function as the first argument to interact with an integer argument e.g. (x=10), a slider will be generated.

Slider Widget Extension

2. Date picker Widget

The date picker widget works in Chrome and IE Edge but does not currently work in Firefox or Safari as they do not support the HTML date input field.

Date picket calender widget

You can find widgets extension docs here.

Conclusion

These were a list of extensions available in the Jupyter Notebooks that I found useful. They have helped me in improving my efficiency while checking the execution time of cells, reducing repetitive tasks. nbextensions package provides many other extensions. Do check them out and try to see which ones you find useful. Hopefully, they will be able to save you some time and provide you a better UI experience. Also, feel free to suggest other useful features in the comments.

If you have any comments or questions feel free to leave your feedback below. Follow me up at Medium.

Start your Data Science Journey here.

Leave a Comment