Jupyter notebooks

A Jupyter notebook is an interactive computational environment that allows you to write and run code, visualize data, and write narrative text all in the same place. It’s a popular tool among data scientists and is commonly used for data analysis, machine learning, and scientific computing. Jupyter notebooks support multiple programming languages, but the most common language used is Python. You will notice that many of our “worked examples” are built in Jupyter notebooks so you can test run some of this code as soon as you have understood what the notebooks are, how to set them up on your computer, and how to run code in them.

Key features of Jupyter notebooks include:

  • Code execution: You can write and run code in the notebook, and see the output immediately.

  • Markdown cells: You can write text in Markdown format to provide explanations, documentation, or commentary on your code.

  • Rich output: You can display images, plots, and other media directly in the notebook.

  • Reproducibility: Notebooks are a great way to document your code and analysis in a way that is easy to share and reproduce.

  • Interactive widgets: You can create interactive elements like sliders, buttons, and dropdowns to explore your data or control your code.

Installing Jupyter notebooks

To install Jupyter notebooks, you can use the pip package manager, which comes pre-installed with Python. To install Jupyter, you can use the following command:

pip install jupyter

This will install the Jupyter package and all its dependencies.

Running Jupyter notebooks

Once you have installed Jupyter, you can start the Jupyter notebook server by running the following command in your terminal:

jupyter notebook

This will open a new tab in your web browser with the Jupyter notebook interface. From there, you can create a new notebook, open an existing one, or run code in the notebook cells.

Basic usage of Jupyter notebooks

Once you have opened a Jupyter notebook, you can start writing and running code in the code cells. To run a cell, you can press Shift + Enter or click the “Run” button in the toolbar.

You can also add new cells by clicking the “+” button in the toolbar, and you can change the cell type from code to Markdown by selecting the cell type from the dropdown menu.

Notebooks are automatically saved as you work. You can also save them manually by clicking the “Save” button in the toolbar or pressing Ctrl + S.

Additional Resources

If you’re new to Jupyter notebooks, here are some great places to start: