Jupyter Notebook is a web-based application to execute code, document, display visualizations, etc all inside of a single notebook. You can create and share notebooks containing text, live code, visualizations, etc. It is this versatility that has made Jupyter Notebooks one of the most popular data science tools. Not only are these notebooks preferred by data scientists but they’re also quite popular among researchers across the globe.
In this introduction, we’ll give a complete overview of Jupyter Notebooks to get you up and running with this wonderful tool.
Table of Contents
- Jupyter Notebook Installation
- Jupyter Notebook Basics
- Starting the Jupyter Notebook server
- The Notebook Interface
- Menu Bar
- Tool Bar
- Types of Cells
- Running Cells
- Exporting Notebooks
- Additional Resources
Jupyter Notebook Installation
To install Jupyter Notebook, we recommend you install Anaconda, which not only installs python and Jupyter Notebook for you, it also installs other important tools like Spyder, RStudio, etc as well. The installation process is relatively simple.
- It’s recommended that you download the latest Python 3 version of the installer. Navigate to Anaconda’s Individual Edition’s page and download the Anaconda installer depending on your system requirements.
- Install anaconda from the downloaded installer. During the installation process, provide your preference on how you’d like the anaconda to be installed. For more details, you can follow this guide or use the default configurations if you’re not sure.
- On Successful installation, you’d be able to open up the Anaconda Navigator. Using the Navigator you can open a bunch of programs including Jupyter Notebook.
Jupyter Notebook Basics
A Jupyter notebook, simply, is a series of cells. Inside each of these cells, you can either execute code or show some text. And, based on the input in a cell, we get an appropriate output on execution.
1. Starting the Jupyter Notebook server
The Jupyter Notebooks server is the backend that powers the notebooks running on the browser. You can use the following methods to start the Jupyter Notebook server:
Method-1: From Anaconda Navigator
Open up the Anaconda Navigator. Based on your application’s version, you’d see a window like this:
From the navigator, in the Jupyter Notebook section, click
Method-2: From Anaconda Prompt
Open up the Anaconda Prompt, inside the prompt type
jupyter notebook and hit enter.
- Harvard University Data Science: Learn R Basics for Data Science
- Standford University Data Science: Introduction to Machine Learning
- UC Davis Data Science: Learn SQL Basics for Data Science
- IBM Data Science: Professional Certificate in Data Science
- IBM Data Analysis: Professional Certificate in Data Analytics
- Google Data Analysis: Professional Certificate in Data Analytics
- IBM Data Science: Professional Certificate in Python Data Science
- IBM Data Engineering Fundamentals: Python Basics for Data Science
- Harvard University Learning Python for Data Science: Introduction to Data Science with Python
- Harvard University Computer Science Courses: Using Python for Research
- IBM Python Data Science: Visualizing Data with Python
- DeepLearning.AI Data Science and Machine Learning: Deep Learning Specialization
- UC San Diego Data Science: Python for Data Science
- UC San Diego Data Science: Probability and Statistics in Data Science using Python
- Google Data Analysis: Professional Certificate in Advanced Data Analytics
- MIT Statistics and Data Science: Machine Learning with Python - from Linear Models to Deep Learning
- MIT Statistics and Data Science: MicroMasters® Program in Statistics and Data Science
🔎 Find Data Science Programs 👨💻 111,889 already enrolled
Disclaimer: Data Science Parichay is reader supported. When you purchase a course through a link on this site, we may earn a small commission at no additional cost to you. Earned commissions help support this website and its team of writers.
Either of the methods will start the notebook server. Choose whichever method you’re comfortable with. This will open up the Jupyter Notebook web application in your browser and you’d see a file-explorer view of location you’ve opened the notebook from.
Now that we’ve started the notebook server it’s time to create a new notebook. To do so, follow these steps:
- Navigate to folder where you’d like to save the notebook.
- Click New -> Python 3.
As a result, you’d see a new notebook open up in another tab.
2. The Notebook Interface
There are four significant elements of the Jupyter Notebook interface: the notebook name, the menu bar, the toolbar, and the code cells.
You can see the name of your notebook next to the Jupyter logo. To change it, simply click on the name. This opens up a prompt asking you for a new name. It’s a good practice to give clean and logical names to your notebooks to avoid any confusion later on.
The menu bar has different menus that help us interact with the notebook. The menu bar functions similarly to the menu bar in general applications you may have used in the past. We won’t be covering each and every part of it in detail as it’s beyond the scope of this introduction. But, some of the important functionality of the menu bar includes:
Save and Checkpoint: Under the file menu, you have the option to save and create a checkpoint in your notebook. It’s one of the jupyter notebook best practices to periodically checkpoint your notebook so that you revert back to them if required.
Kernel: The kernel menu helps to manage to kernel powering your notebook. You can interrupt, reconnect, restart, clear the output, or even shut the kernel down altogether using it.
One of the criticisms of Jupyter Notebook is that if the cells are not executed in sequential order, it becomes quite difficult to track them. Thus, it becomes necessary to restart the kernel and run the cells from top to bottom. As one Twitter user put it, “Restart and run all or it didn’t happen.”
The toolbar has some quick access buttons for manipulating the cells. Whether it’s adding/removing a cell, shifting it, copying it, running it, or entirely changing the type of cell itself, all can be done from the toolbar.
Functionally, a Jupyter Notebook has two components. Users input programming code or text in rectangular cells on a front-end web page. The browser then passes that code to a back-end ‘kernel’, which runs the code and returns the results.
Types of Cells
A cell is a multiline text input field. The execution behavior of a cell depends upon the type of the cell. There are three types of cells: code cells, markdown cells, and raw cells.
Code cells: A code cell allows you to write and execute code. When you run a code cell, the code inside it is sent to the kernel associated with your notebook. The results from the kernel are displayed as output immediately below your cell.
Markdown cells: Markdown cells allow you to display text. The specialty of these cells is that they allow you to markup your text with the Markdown language. Thus, instead of having just plain text, we can format our text which rich features like headings, lists, bold, italics, etc. For more on markdown check out this guide.
Raw cells: Raw cells allow you to write output directly. These cells are not evaluated by the notebook. Instead, they’re used when you convert your notebook to another format such as HTML or Latex. For more on raw cells, refer to the documentation.
Each cell starts off as a code cell but its type can be changed using a drop-down on the toolbar.
For most purposes, you’d be dealing with Code and Markdown cells only.
To run a cell, you can use either of the following methods:
Enter, this is the short-cut to run a cell.
- Click the “Run” button on the toolbar.
- From the menu bar, go to Cell->Run Cells
Based on the type and contents of the cell, a corresponding output would be displayed below the cell.
4. Exporting Notebooks
Jupyter Notebooks by default are saved as
.ipynb files. You can share these files with your colleagues who can open, execute, modify, re-execute it running it on the Jupyter Notebook server.
At times, you may also want to share your notebooks with non-technical people. Particularly, for sharing some results. For this, you can save your Jupyter notebook as an HTML file or one of the formats (shown in the image below) which can be opened without the Jupyter Notebook server.
This completes our tutorial on Introduction to Jupyter Notebook. With the topics covered in this tutorial, we hope that you received a good introduction to this tool which is basically a Swiss Army Knife in Data Scientist’s toolkit.
A highly recommended next step would be to try things out. Create your own notebooks, play around with what you can do, and maybe come up with some really cool notebooks and share your learnings along the way.
If you’d like to have a deeper dive into all the features and capability of Jupyter Notebooks, do check out the official documentation.
Also, if you’re interested in learning in data science and want to learn python, check out our series Python for Data Science