Every day the number of Python notebooks grows. Developers around the world have fully embraced Jupyter Notebook and now it’s become a must-have in the industry.
I first noticed this trend in 2019, but back then I didn’t feel inspired to change, but in 2020 more and more developers embraced Jupyter Notebooks. I saw Python developers praising Jupyter Notebook on YouTube and taking it for granted that everyone else was a convert too.
What Are the Advantages of Jupyter Notebook?
- Convenient for the initial development of code
- Segment your code (and re-run segments)
- Store values of variables from segments you’ve already run
Ultimately at the end of 2020, I made the leap to understand how Jupyter Notebook works. How great could it be? Now I’m one of those converted developers. It feels like I’ve always used Jupyter Notebook; like it’s always been there. It’s really come to feel like the simplest tool in the world. It won’t replace your regular Python environment but it will drastically enhance it.
Why Use Jupyter Notebook?
Jupyter Notebook is convenient for the initial development of code. It allows you to segment your code (and re-run segments of your code) while storing the values of variables from segments you’ve already run. Here’s an example:
Here is the same notebook on GitHub.
As you can see in this example, each cell runs separately. This is great when a certain part of your code contains never-ending arrays or a machine learning training operation. With Jupyter you can run these long operations once, create a new cell below, and use the values you obtain from previous cells.
Another situation where developers often use Jupyter is to create documentation or tutorials for their team. You can explain your thought process much better in a notebook rather than using internal comments within your code.
How to Install and Use Jupyter Notebook
I took the liberty of creating a tutorial explaining how to install and use Jupyter Notebook ... in a Jupyter Notebook.
You can access the notebook from GitHub.
A Caveat: Jupyter Notebook Isn’t Always Your Best Tool
Despite how useful Jupyter is, it still doesn’t replace an integrated development environment (IDE) like PyCharm or Visual Studio Code. If you need to create long, self-contained classes or just pack your code for submission you might prefer moving your code from Jupyter to an IDE. Jupyter is great for development, but once you’ve done the developing, it isn’t the best place for constant implementation.
Another important difference to consider is code completion. By default, Jupyter Notebook offers weak code completion features when compared to an IDE like PyCharm, so you better know your code well.
Jupyter also offers JupyterLab (a relatively new environment) alongside Jupyter Notebook. I have to warn you off using JupyterLab instead of Jupyter Notebook, though. I’ve tried both and I’ve found JupyterLab lacks certain key functionalities you find in Jupyter Notebook.
Don’t Take My Word for It
Many developers and researchers are involved with projects that require Python on a daily basis. Regardless of your coding skills, Jupyter Notebook adds value to a backend or (especially) analytics team. Jupyter provides a framework and interface that encourages good knowledge management practices by allowing for clear documentation and chronological explanation of the implemented code.
In the end, if you use Python regularly but don’t use Jupyter Notebook (yet), then you might want to reconsider your life choices. I did.