JupyterLab Cheat Sheet

Tips and tricks for the next stup in Project Jupyter evolution.
Published

January 22, 2022

JupyterLab Cheat Sheet

by Eric M. Baumel

JupyterLab is the latest iteration of the popular interactive Python notebook environment, inheriting from iPython and Jupyter Notebooks. See Project Jupyter.
JupyterLab provides the interactive notebook format of Jupyter Notebooks, with an integrated file borwser, console and more.

You install JupyterLab either from Anaconda or via pip with: pip install jupyterlab.

You launch the JupyterLab server from the command line with jupyter lab.

If your browser doesn’t launch by itself, you go to http://localhost:8888/lab

A iPython notebook file .ipynb can be opened with either Jupyter Notebok or JupyterLab.

JupyterLab Interface Shortcuts

  • Toggle the sidebar with Cmd + B
  • Save the notebook with Cmd + S
  • Save As with Shift + Cmd + S
  • Close a tab with Option + W or Alt + W

Running a Cell

  • To execute a cell and move tho the next cell in command mode click the run button in the toolbar or use Shift + Enter on the keyboard

  • To execute the cell and stay on that cell use Ctl + Enter

  • Interupt a Running Cell with II

Toggle Between Command and Edit Modes

  • Change to Command mode with the ESC key
  • Change to the Edit mode with the Enter key

Command Mode Keyboard Shortcuts

Move between cells with the up and down arrow keys

  • Create a cell above the active cell with the A key

  • Create a cell below the active cell with the B key

  • Delete the active cell with DD

  • Undo a cell with the Z key

  • Copy a cell with the C key

  • Paste a cell with the V key

  • Change to markdown mode with the M key

  • Change to code mode with the Y key

Code Completion

The Tab key gives you a list of possible class or function choices.

Shift + Tab shows a tooltip of the fucion or class the cursor is on.

Markdown Basics

Adapted from: https://www.markdownguide.org/basic-syntax/

Headings

To create a heading, add number signs (#) in front of a word or phrase. The number of number signs you use should correspond to the heading level.

For compatibility, always put a space between the number signs and the heading name. Also, put blank lines before and after a heading for compatibility.

Example:

# Heading 1: Document Title

## Heading 2: A subtitle

Heading 1: Document Title

Heading 2: A subtitle

Line Breaks

To create a line break or new line <br>, end a line with two or more spaces, and then type return.

Example:
A line break <br> here.
A line break
here.

Text Formatting

Bold Text - **Bold Text**
Italics Text - *Italic Text*
BoldItalics - ***BoldItalic Text***

Code

To show a word or phrase as code, enclose it in backticks (`).

Example:

Install a library with, pip install jupyterlabs.

Code blocks are normally indented four spaces or one tab. When they’re in a list, indent them eight spaces or two tabs. You can also enclose the codeblock thith three backticks (``), or three tildes~~~`.

# Imports
import pandas
import numpy

Images

![alt text](image.jpg)

Blockquotes

The Greater Than sign > offsets blockquotes.

> Think globally, act locally. is rendered as: > Think globally, act locally.

Lists

Unordered Lists

Use a dash - for unorderd list:

  • An Unordered List Item - An Unordered List Item
    • Another List Item - Another List Item

Ordered Lists

  1. To create an order list, start the line with a number and a period. 1. To create an order list...
  2. If you need to use a number at the start of a list item, you escape the period by adding a backslash character \ after the number, but before the period: 2022\. That's the year I wrote this.