Using Jupyter Notebooks

How to use a Jupyter notebook

Executing code in a Notebook: Jupyter notebooks provide “cells” within which is typed either Python code or markdown language (for formatted text). Choose the cell to execute by clicking in it with the mouse (the cursor must be in the desired cell). Hold down the shift key and press either enter or return (depending on keyboard type), or click the ‘Play’ button in the notebook toolbar, and the contents of the cell will be executed. If the cell type is code, and the cell contains python code, the code will be executed. If the cell type is markdown, then it will be rendered upon execution to yield nicely formatted text. There is a user guide for markdown cells in the Jupyter Notebooks documentation.

This image is a screenshot of the tutorial notebook entitled Introduction to Jupyter Notebooks for Data Preview 0.2. The notebook has been scrolled down to Section 3.3, which contains both markdown text and code cells which have been executed. The last code cell has produced a greyscale image of a rich galaxy cluster. Across the top of the notebook there is a menu bar of actions for users. Actions include save notebook, set cell type, and insert, cut, copy, paste, run, or interrupt cells.

A screenshot from a Rubin/LSST tutorial notebook, showing the panel of the Notebook Aspect where multiple interface tabs can be open at once. In this case, the first tab is a command-line terminal, the second is the Launcher interface, and the third (which is currently selected) is an executed version of a tutorial notebook. Multiple notebooks can be opened in separate tabs.

Opening Multiple Notebooks: Multiple notebooks and terminals can be open at a time. Notebooks and/or terminal windows can be arranged next to or on top of each other by dragging the notebook or terminal around by the top bar. Arranging the windows can be convenient when working in both a terminal and notebook at the same time, or when using another notebook as a reference.

JupyterLab Autosaves Notebooks: Note that JupyterLab autosaves notebooks at a default interval of 2 minutes unless working in the directory “notebooks/tutorial-notebooks/”, which is read-only (see How to use the Tutorial Notebooks).

How-to guides