10 Essential Jupyter Notebook Extensions for Data Scientists | Towards Data Science

IntroductionExtensionsSummaryReferences
Introduction
Extensions
Summary
References
As a Data Scientist who primarily works in Jupyter Notebook, I have experienced several pros of development in my notebook, while also encountering many various issues as well. Some of those issues can be solved by jupyter_contrib_nbextensions [2]. If not solved, then the notebook can be enhanced. This Python package has numerous nb extensions that you can configure that help to make your Data Science development process easier. It is important to note that once you install this package, you will need to restart your notebook from your terminal to see its effects. Below, I will be describing the top 10 or essential Jupyter Notebook extensions that have helped me in my Data Science process.
As you can see from the above screenshot, there are a ton of extensions that you can enable to make your Jupyter coding and Data Science development easier. I have selected and enabled the 10 extensions that I will also be describing down below. There are a few clicked that come pre-clicked already like the jupyter-js-widgets/extensions, which shows the widgets and icons once you enable your extensions. Similarly, there is also Nbextensions edit menu item already preselected.
Code prettify
This extension helps to prettify or correctly format your Python code in your Jupyter Notebook cells. You can click on the icon to reformat your code in your current cell. Here is a before and after the execution of this extension down below. This code was already nicely formatted to start off so I wanted to show that it created formatted spacing correctly on the right. For some notebooks, it might be a small change, but for others, you may have hundreds of functions that are improperly formatted and this extension can fix your formatting almost instantly.
Collapsible Headings
If you structure your Jupyter Notebook with headings, you can collapse the information and cells within that same heading section with the down arrow to the left of the heading. Here is the before and after for Collapsible Headings. It is useful when you have, say 10 headings for one notebook and you want to only highlight one heading section during a code review or stakeholder meeting, or even just for yourself to help you focus more on one section. There are also more important parameters that can add to your extension, in addition to options, CSS, internals, and exporting changes (these, as well as other further implementations, are included for most extensions once you install this library).
Notify
This extension allows your notebook to send you a web notification when your kernel becomes idle. If you have a long task running, this extension can be useful by becoming aware of your current process. You can have options of 0, 5, 10, and 30 seconds as well. Here is the dropdown menu example in your notebook.
Codefolding (and Codefolding in Editor)
This is perhaps my favorite extension. Similar to the Collapsible Headings, this extension folds your code sections so that you can more easily scroll and view your notebook.
If you have a long dictionary or a long function, you can collapse them so that they are mainly hidden but still show the function naming so that you can still see the main part. In the example below, you can see how the function is now collapsed, you can even collapse up to the comment level to hide both functions and keep the text of your comment only. The purple arrows icon shows that your code is there, but hidden. This extension is beneficial when sharing your code with others or when you would like to focus on certain parts of your notebook.
highlighter
This extension is rather simple and self-explanatory. You can highlight your markdown text by clicking on the highlighter icon. You can see that there are a few options like red with yellow used below. Here is the before and after of this easy, yet useful extension.
spellchecker
Also simple, yet useful, is the spellchecker. This extension is especially useful if you are sharing your notebook, pushing it to GitHub, or displaying it to stakeholders. You will want to make sure you have correctly spelled your words in your markdown cells. You will not see misspelled words show up in your displayed markdown, but only in your edit. This feature is beneficial so that if you do have some words that you disagree on with the spellchecker, like Jupyter Notebook (is not actually Jupiter Notebook), you can still display it without a distracting, red, highlighted text.
Code Font Size
If you want to change the code font size, this extension allows you to do that. When sharing and collaborating, especially sharing your screen, this feature can prove to be beneficial so that your code is easier to view.
datestamper
This extension allows you to paste your current date and time into your cell. I recommend saving it as a markdown so that the formatting does not run as code with hard-to-see formatting. If you want to keep track of when you started a process that involved different cells and functions, this extension can be useful (on top of the popular tqdm library).
Scratchpad
This extension is incredibly useful. You can use your scratchpad as seen below, by selection Ctrl-B on your keyboard. You can modify the current code that can work off the same kernel as well. It is also useful for viewing side-by-side code and comments if you need to compare them within your notebook.
Skip-Traceback
This unique extension allows you to ignore some of the duplicate or long error messages you see in your Jupyter Notebook cells. It works similarly to the Collapsible Headings and Codefolding. In the screenshot below, you can see how the main part of the error is still there on the right, but reduces the duplicate error information that can sometimes cause a headache and overwhelm you from fixing that same error.
So there you go, these were 10 essential Jupyter Notebook extensions for Data Scientists or anyone else who likes to code and develop in a Jupyter Notebook as well. I hope you learned some new tricks that can make your job as a Data Scientist easier. Keep in mind that there are plenty more extensions to explore as well. These are some that I find particularly interesting and useful.
Here are all of the extensions I mentioned above in one spot:
Code prettifyCollapsible HeadingsNotifyCodefoldinghighlighterspellcheckerCode Font SizedatestamperScratchpadSkip-Traceback
Thank you for reading! Please comment down below if you have had an experience with any of these or other Jupyter Notebook extensions.
[1] Photo by Brett Ritchie on Unsplash, (2018)
[2] Jupyter Contrib Team, jupyter-contrib-nbextensions, (2015–2018)
[3] M.Przybyla, NBextensions tab screenshot, (2020)
[4] M.Przybyla, Before and after prettify screenshot, (2020)
[5] M.Przybyla, Before and after Collapsible Headings screenshot, (2020)
[6] M.Przybyla, Notify dropdown menu screenshot, (2020)
[7] M. Przybyla, Codefolding example screenshot, (2020)
[8] M.Przybyla, Before and after of the highlighter extension screenshot, (2020)
[9] M.Przybyla, Spellcheck example screenshot, (2020)
[10] M.Przybyla, Scratchpad example screenshot, (2020)
[11] M.Przybyla, Skip-Traceback example screenshot by Author, (2020)
[12] Photo by Jess Bailey on Unsplash, (2018)