We have the answers to your questions! - Don't miss our next open house about the data universe!

Jupyter Notebook: An indispensable code-sharing tool

- Reading Time: 4 minutes
Jupyter Notebook

Jupyter Notebook is a web application that lets you create electronic notebooks capable of combining text, images, computer code or equations, all in the same document. In the interests of readability and document source code utilization, it's best to run the application from the same interface, and see changes in real time. This is exactly what Jupyter Notebook offers.

Originally developed for Julia, Python and R (Ju-Pyth-R), the application now supports over 40 different languages. Find out all you need to know about this tool, which is widely used by developers, but is also indispensable in Data Science.

What is Jupyter Notebook?

Jupyter Notebook is an open-source web application for creating and sharing documents. Formerly known as IPython Notebooks, it is a web-based interactive computing environment enabling Python users to create notebook documents.

The term “notebook” refers to a variety of entities, including the Jupyter web application, the Jupyter Python web server, or a Jupyter document. Notebooks are code cells that can be documented with text or data to explain their execution. All these cells are stored in a document that can be shared with other users.

This tool has numerous use cases: data cleansing and transformation, digital simulation, statistical modeling, Machine Learning…

What is the Jupyter Notebook App?

The Jupyter Notebook App is a server-client application. It lets you edit and run notebooks via a web browser. The application can be run on a PC without Internet access, or installed on a remote server that can be accessed via the Internet.

The two main components of this application are the kernels and the dashboard. A kernel is a program that executes and inspects user code. The Jupyter Notebook App has a kernel for Python code, but there are also kernels for other programming languages.

The application’s dashboard presents Notebook documents created by the user, and allows them to be opened again. It can also be used to manage kernels, including enabling and disabling them.

How do I install Jupyter Notebook?

The Jupyter Notebooks installation process varies according to the method used. Here’s how to proceed in different cases:

With the Anaconda Python distribution, you must use Python 3.3 or higher, or Python 2.7. We recommend using the Anaconda, Azure or Miniconda distribution to install both Python and the notebook application. The advantage of Anaconda is that it offers access to over 720 packages, which can be easily installed with the Conda manager.

Another alternative is to run Jupyter Notebooks on a Docker container. Simply install the Docker Toolbox, containing all the tools you’ll need to set up your containers. After installation, choose the “Docker QuickStart Terminal” and tell it to install the Kitematic Visual Management tool if you don’t already have a virtualization platform.

Then use the “docker run” command to launch Docker images. A simple command will launch the official Jupyter Notebook image on your Docker container. The most recent Jupyter HTML Notebook image will be downloaded, and you can start using the application.

How do I use Jupyter Notebooks?

Once installation is complete, you can start using Jupyter Notebooks. After using the open command in a shell:

$ jupyter-notebook

the application opens in your web browser at “http://localhost:8888“.

Your files are stored in the “Files” tab. Process monitoring can be viewed in the “Running” tab, and IPython’s parallel computing framework is accessible from the “Clusters” tab.

The “new” button in the “Files” tab lets you create a new notebook by selecting “Python 3”.

You can then rename your notebook by clicking on “Untitled”. Your notebook will contain an empty cell which you are free to fill with text, images or code.

If you wish to run your cell, you can click on the “Cell” menu, then “Run Cells”, the “Run” button or enter the shortcut ctrl + enter.

How do I share Jupyter Notebooks?

There are many ways to share your notebooks. The aim may be to collaborate with colleagues on a project, or to build up a Data Science portfolio for future interviews.

Notebooks take the form of shareable .JSON documents containing text, source code, multimedia elements and metadata. Each segment of the document is stored in a cell.

However, we advise you not to share JSON files to avoid problems of data corruption. Alternatively, you can go to the application’s “File” tab. An option allows you to download the notebook in HTML, PDF, Markdown, reStructuredText, Python script or Notebook file format.

The “nbconvert” command can also be used to convert a notebook file to another static format such as HTML, PDF, LaTex, Markdown or reStructuredText. Simply import this command.

How do I access JupyterLab?

Since 2018, the companies behind Jupyter have launched a complete analysis environment, JupyterLab. This interface is obtained with the command: $ jupyter lab and enables several new features such as the incorporation of an insert into your notebook.

Jupyter Notebook and Data Science: best practices

In the field of Data Science, Jupyter Notebook is widely used for project collaboration. It’s a valuable tool for teams of data scientists. However, it’s best to adopt certain practices to make the most of these benefits.

First of all, it’s best to use two types of notebook for a Data Science project: a lab notebook, and a “deliverable” notebook. Only the latter will be shared and manipulated by the whole Data Science team.

You can also use versioning control tools such as Git or Github. This will allow you to approve or reject each modification made by team members. This way, everyone can work independently and share the results.

If your version control system doesn’t have rendering capabilities, it’s important to share the HTML file. Finally, apply explicit rules to document naming. This will avoid any confusion.

How do I learn to use Jupyter Notebooks?

Jupyter Notebooks are very useful for any computer programming project, especially Data Science. To learn how to use it, you can look to the best notebooks for inspiration.

Some books come with a notebook, such as the Python Data Science Handbook. There are also high-quality tutorials on the web, accessible free of charge via platforms such as YouTube.

To master Jupyter Notebook, you can choose DataScientest training courses. Jupyter Notebook is at the heart of our Data Scientist and Data Analyst training programs.

At the end of these courses, you’ll have all the skills you need to become a Data Science professional. Our students receive a diploma certified by Mines ParisTech PSL Executive Education, and 80% of our alumni have found a job after their training.

Our training courses adopt a hybrid Blended Learning format, combining individual coaching and masterclasses. They can be taken in intensive BootCamp mode, or as Continuing Education.

What’s more, you can finance our training courses via the Compte Personnel de Formation (Personal Training Account), or thanks to the AIF from Pôle Emploi. Don’t waste any more time and discover DataScientest’s programs!

You are not available?

Leave us your e-mail, so that we can send you your new articles when they are published!
icon newsletter


Get monthly insider insights from experts directly in your mailbox