10 Lesser Known Facts About ‘Jupyter Notebook’

Vishnu Viswanath
9 min readFeb 19, 2023

--

Thumbnail Created Via Canva

Jupyter Notebook is a really cool web-based application that data scientists and researchers use to write and share code, data, and visualizations. But, did you know that there are some secret features and tricks that most people don’t know about? In this article, we’re gonna uncover some hidden gems that can help you be a better and faster Jupyter Notebook user. We’ll be talking about shortcuts, extensions, and other neat stuff that can really make your life easier. So, whether you’re a total newbie or a Jupyter Notebook pro, keep reading to find out some of the cool things you can do with this amazing tool.

1. The Origin: From IPython to Open Source Powerhouse.

Jupyter Notebook is an awesome open-source tool that used to be called IPython Notebook. Back in 2014, Fernando Perez and his team of developers came up with it, and it’s now one of the hottest things in the data science world. It was actually inspired by Mathematica, which is a fancy commercial software package for technical computing. But the best thing about Jupyter Notebook is that it’s open-source, so anyone can use it for free. That’s why it’s so popular with people who do research, data science, and programming.

2. The Art of Literate Programming

Jupyter Notebook has revolutionized the world of data science by providing a platform for “literate programming”. This approach allows the programmer to interweave code and explanatory text in a single document. This approach has several advantages, including the ability to document code easily and test code in small sections, making it easier to identify and fix errors.

Jupyter Notebook is particularly useful for data scientists who need to share their work with others. It allows them to document and explain their code, explore data, analyze it, and create reports all within the same platform. Its versatility and efficiency make it a popular tool in the data science community. It’s like a Swiss Army knife for data analysis.

3. How “Jupyter” Got Its Name: The Fascinating Story Behind it

Jupyter Notebook owes its name to the three main programming languages it supports: Julia, Python, and R. The name is a clever play on words that combines “JULia”, “PYThon”, and “R”, the first letters of each language. This unique name not only highlights the tool’s functionality but also demonstrates the community-driven nature of Jupyter Notebook.

Data scientists and developers frequently use various programming languages to perform diverse tasks. Jupyter Notebook’s capability to support three widely used programming languages in one platform is a major breakthrough for those who require the flexibility to work across different domains. This has made Jupyter Notebook an indispensable tool for individuals who work with data from multiple sources and need to perform different analyses.

4. Beyond Python: The Multitude of Programming Languages in Jupyter Notebook

One of the most impressive features of Jupyter Notebook is its ability to support a vast array of programming languages. This means that Jupyter Notebook can be used for much more than just Python programming, with over 40 different programming languages supported.

Despite the extensive list, Python remains the most commonly used language in the Jupyter community, partially due to the fact that Jupyter Notebook was initially developed as a Python-specific tool. However, it has since expanded into a more general-purpose tool for scientific computing and data science.

In addition to Python, Jupyter Notebook supports many other popular languages, including R, Julia, and MATLAB, as well as niche languages such as Lua, F#, and Haskell. As a result, Jupyter Notebook has become a powerful tool for data scientists, researchers, and developers who work with various programming languages.

5. Running Kernels for Different Languages in Jupyter Notebook

One of the most powerful features of Jupyter Notebook is its ability to run kernels for different programming languages. By default, Jupyter supports several popular programming languages like Python, R, and Julia. However, you can also install additional kernels for less popular languages or for specific versions of a language.

For example, if you need to work with R code in Jupyter, you can install the R kernel by running the command conda install -c r r-essentials in your terminal or Anaconda Prompt. This will install the necessary packages and dependencies for running R code in Jupyter. Once the installation is complete, you can start a new Jupyter Notebook and choose the R kernel from the list of available kernels.

You can also install Julia by running the command conda install -c conda-forge julia

6. Abracadabra: Unleashing the Magic Commands of Jupyter Notebook

Jupyter Notebook is a pretty cool environment, but what sets it apart is its use of “magic commands”. These commands are like little wizards that can help you do all sorts of things, from timing how long your code takes to execute, to debugging, and even running shell commands right from your code cell.

To use a magic command, you just add a “%” or “%%” sign before the command, depending on whether you want to execute it on a single line or the whole cell. You can even create your own custom magic commands to make your workflow even smoother.

Here are some of the popular magic commands that you may want to try out:

  • %time: Measures the execution time of a Python statement or expression.
  • %timeit: Measures the average execution time of a Python statement or expression over multiple runs.
  • %%bash: Executes a bash script in the current kernel.
  • %env: Sets environment variables for the current session.
  • %debug: Activates the interactive debugger.
  • %prun: Runs a Python statement with the profiling tool cProfile and displays the results in a tabular format.
  • %load_ext: Loads an IPython extension by its module name or alias.
  • %run -p: Runs a Python script with the profiling tool cProfile and displays the results in a tabular format.
  • %history -n: Shows the command history of the current session with line numbers.
  • %reset_selective: Resets specific variables in the namespace.
  • %store: Stores a set of variables or aliases.

7. Enhancing Jupyter Notebook with Extensions

Jupyter Notebook offers a variety of extensions that can enhance your experience when using the tool. These extensions provide additional functionalities such as improved editing capabilities, code cell formatting, and much more.

To install the extensions, you can use the following command:

pip install jupyter_contrib_nbextensions && jupyter contrib nbextension install

This command installs the Jupyter Notebook extensions package and then installs the extensions.

Once installed, you can access the extensions from the main menu by clicking on the “Nbextensions” tab. From here, you can enable or disable individual extensions as needed.

Extensions in Jupyter Notebook

Some of the popular extensions available in Jupyter Notebook include:

  • Autopep8: automatically formats Python code to conform to the PEP 8 style guide
  • Table of Contents: generates a table of contents for your notebook
  • Collapsible headings: allows you to collapse and expand headings in your notebook
  • RISE: creates interactive slideshows from your notebook
  • Snippets menu: provides a collection of commonly used code snippets for faster coding

You can find the full list of available extensions in the Official Jupyter Notebook documentation.

8. Transforming Jupyter Notebooks into Web Applications with Voila

One of the most useful features of Jupyter Notebook is the ability to create interactive and sharable notebooks that contain not only code but also text, visualizations, and data. However, for you to share these notebooks with others, the recipient must have Jupyter Notebook installed, which can be a barrier for some users.

The “voila” feature in Jupyter Notebook allows you to turn your notebooks into standalone web applications, without any code changes. This means you can share your data science projects and interactive visualizations with others, even if they don’t have Jupyter Notebook installed on their computer.

To use the “voila” feature, you need to install the “voila” package by running the following command in your terminal or command prompt:

pip install voila

Once you have installed the “voila” package, you can use it to run your Jupyter notebooks as standalone web applications by adding the “ — no-browser” and “ — port” options to the “voila” command:

voila --no-browser --port 8888 your_notebook.ipynb

This will launch the “voila” server and open your notebook in a web browser. You can then share the URL of the web application with others, who can access it from their own web browser.

9. Showcasing your Ideas: Jupyter Notebook Presentations with RISE

Wow your audience with interactive presentations using Jupyter Notebook’s “RISE” extension! With “RISE” (Reveal.js — Jupyter/IPython Slideshow Extension), you can create presentations that mix markdown and code cells for a dynamic experience.

During your presentation, you can navigate with ease using arrow keys, run code cells in real-time, and even add speaker notes. And if you want to stand out, you can customize your presentation’s appearance with CSS styles and themes. So why settle for boring slides when you can bring your presentations to life with Jupyter Notebook’s RISE extension?

To use RISE, you should install the extension first. You can install it by using this pip command:

!pip install RISE

After the installation is complete, you need to enable it using the following command:

!jupyter-nbextension install rise --py --sys-prefix
!jupyter-nbextension enable rise --py --sys-prefix

Once RISE is installed and enabled, you can create a new notebook and start adding slides to your presentation using markdown cells. You can also add code cells and run them during the presentation.

To start the presentation, you need to enter the “RISE” slideshow mode by clicking on the “Enter/Exit RISE Slideshow” button in your Jupyter toolbar. You can then use your arrow keys to navigate through the presentation and run code cells during the presentation.

10. Exploring Widgets in Jupyter Notebook

Jupyter Notebook is equipped with a versatile collection of interactive widgets that enable you to create a diverse range of user interfaces right within the notebook environment. These widgets include interactive plots, sliders, dropdown menus, and various other graphical user interface (GUI) components that can take your notebooks to the next level. In this section, we’ll delve into one of these widgets and provide examples of other widgets you can utilize.

One of the most basic widgets that you can use is the slider, which allows you to adjust a numeric value by sliding a widget back and forth. Here’s an example:

from ipywidgets import interactdef f(x):
return x * x
interact(f, x=(0, 10, 1))
Interact Widget

In addition to sliders, there are many other widgets you can use in Jupyter Notebook, including:

  • Dropdown: Allows you to select from a list of options.
  • Checkbox: Allows you to select one or more options.
  • Textbox: Allows you to enter text.
  • Button: Triggers an action when clicked.
  • Date picker: Allows you to select a date.

To use these widgets, you need to import them from the ipywidgets module. For example, to create a dropdown, you can use the Dropdown class:

from ipywidgets import Dropdownoptions = ['option 1', 'option 2', 'option 3']
dropdown = Dropdown(options=options)
display(dropdown)
Dropdown Widget

These are just a very few examples of the many widgets you can use in your Jupyter Notebook. With these widgets, you can create a rich, interactive user interface that allow your users to explore and analyze data in a more intuitive and fun way.

Before you go

I hope you enjoyed reading this article and find it useful. Please consider following me on | GitHub | Linkedin | Kaggle |

Vishnu Viswanath

--

--

Vishnu Viswanath
Vishnu Viswanath

Written by Vishnu Viswanath

Data Scientist with experience working with predictive analysis, Data analysis, data visualization and web scraping.

No responses yet