Jupyter Notebook is an online computational notebook that allows you to combine code, comments, media, and visualizations in interactive documents. It has quickly become one of the most popular online computational notebooks, used by top companies such as Google, Microsoft, and NASA. Today, we’re going to explore Jupyter Notebooks and discuss their benefits and how to get started.
Jupyter Notebook is an open-source web application used to create and share documents that have live code, equations, visualizations, and text. It’s maintained by the Project Jupyter community. In 2014, Project Jupyter and Jupyter Notebook became spin-off projects from IPython and the IPython Notebook.
In addition to the Jupyter Notebook, there’s also JupyterLab, which is a web-based IDE for Jupyter Notebooks. It allows you to set up your user interface to support various workflows in machine learning, data science, scientific computation, and more. With JupyterLab, you can run terminals, text editors, and code consoles in your web browser. You can also create your own plugins.
JupyterHub is another offering from Project Jupyter. JupyterHub is a multi-user version of Jupyter Notebook, designed for teams, classrooms, and labs. The hub allows you to deploy your notebooks to your organization, scale your deployment with Docker and Kubernetes, and provide uniform data management and access within your company.
Jupyter Notebook is a popular computational notebook, with over 2.5 million public notebooks available on GitHub. It’s used for a variety of things, such as:
Jupyter Notebook has become the standard computational notebook for data management. It’s used at many top companies, such as Google, Microsoft, IBM, Bloomberg, NASA, and more. Let’s take a look at some of the reasons why Jupyter Notebook is so popular:
Supported languages: Supports over 40 programming languages including Python, Scala, Julia, and R
Sharing capabilities: Ability to share your notebooks with others using email, Dropbox, Github, or Jupyter Notebook Viewer
Interactive output: Code can produce rich output like HTML, LaTeX, images, and videos
Customization: Ability to build custom components and customize JupyterLab to fit your workflow
Usability: JupyterHub allows you to share notebooks with large groups of users and Binder allows you to use Jupyter on GitHub in a browser
Documentation: Great formatting options and inline output
Live coding environments: Code can be changed and run in real-time with feedback provided directly in the browser
Jupyter Notebook is not included with Python, so we’ll have to install it first. During our tutorial, we’ll use Python 3 and not Python 2.
There are a couple of ways to install Jupyter Notebook:
We can use pip to install Jupyter Notebook using the following command:
$ pip install jupyter
We can also use Anaconda, which is a Python data science platform. Anaconda has its own installer named conda that we can use to install Jupyter Notebook. Anaconda comes with some preinstalled libraries, including Jupyter Notebook, so if we already have Anaconda installed, we’re ready to get started working with the notebook.
Note: An additional way to try out Jupyter Notebook is to go to jupyter.org/try. You can select “Try Classic Notebook” to go through a basic tutorial of Jupyter Notebooks and IPython kernel using the classic interface. I will be using this for the tutorial today.
It’s time to get started with Jupyter Notebook! All we need to do is create a new folder and then go to that folder location in our terminal. Then, we can run this command to start Jupyter:
$ jupyter notebook
Now, we can name our notebook. At the top of the screen, we see “Untitled”. Let’s select it and rename our notebook to “Jupyter Notebook Test”.
In the above image, we can see a list of menus on our screen. Let’s discuss what each of these menus does.
File: Create new notebooks or open existing notebooks
Note: We can use “File” to rename our notebooks. “File” also gives us the options to “Save and Checkpoint” and “Revert to Checkpoint”. These options allow us to save our progress at different checkpoints and return back to them if we want to.
Edit: Manipulate our cells
View: Toggle headers, toolbars, and line numbers
Insert: Insert cells above or below the selected cell
Cell: Run our cells
Kernel: Control the kernel
Widgets: Save and clear widget state
Help: Learn about Jupyter Notebook
When we first create a new Jupyter Notebook, the first cell defaults to using code and the kernel we selected at the beginning. Since we started with Python 3, we can run Python code in our cells. Let’s check it out! We can follow these steps:
”print(“Hello World!”)into the first cell
Here’s what our notebook should look like now:
Learn Python data analysis without scrubbing through videos or documentation. Educative’s text-based learning paths are easy to skim and feature live coding environments, making learning quick and efficient.
Let’s practice adding some content to our Jupyter Notebook. In this section, we’ll discuss Jupyter cell types, including code and Markdown.
The main cell types we use are code cells and Markdown cells. We practiced using code cells when we wrote our
Hello World!, so let’s take a look at the Markdown cell type.
We can use the “Insert” menu to insert a cell below our current one. Now, we can change our output type from “Code” to “Markdown”. We won’t spend much time discussing Markdown and its formatting, but let’s practice creating headers and making lists.
To create a header in Markdown, all we need to do is use the pound
# sign. One pound sign makes a heading 1, two pounds signs makes a heading 2, and so on.
Jupyter Notebook previews the headers for us:
When we select “Run”, the cell will format nicely like this:
We can create bullet points in Markdown using single asterisks in place of bullets. Here’s what it’ll look like before we select “Run”:
Here’s what it looks like after we select “Run”:
Now, let’s learn more about how to share our notebooks. Jupyter Notebook comes with a
nbconvert tool, which allows us to convert our
.ipynb notebooks into many different formats including:
nbconvert is simple to use. All we need to do is open up a terminal, go to the folder that stores the notebook we want to convert, and run the command. The command looks like this:
$ jupyter nbconvert <input notebook> --to <output format>
Once we convert the notebook, we can share it however we want!
Congrats on taking your first step with Jupyter Notebook! It’s one of the most popular computational notebooks on the market. There are many more great ways to perform data analysis and visualization with Python. There’s so much left to learn. Some recommended topics to cover next include:
To get started learning these concepts and more, check out Educative’s learning path Python Data Analysis and Visualization. This curated learning path will help you master the skills to extract insights from data using a powerful assortment of popular Python libraries.
Join a community of 500,000 monthly readers. A free, bi-monthly email with a roundup of Educative's top articles and coding tips.