8 Jupyter notebooks
8.1 Overview
8.1.1 Introduction
Jupyter is an independent project that provides
- Jupyter Notebooks: interactive code cells, markdown text, tables, plots, latex math formulas
- Jupyter Lab: web-based interactive development environment (editor)
- Jupyter Hub: multi-user version of notebooks
Jupyter notebook is new version of interactive python notebook that have extension .ipynb
, which is still used.
8.1.2 Objectives
In this book intent is to provide notes and references to get started with jupyter notebooks using jupyter lab. Note that jupyter notebooks can be used independent from jupyter lab. There are other editors which support using jupyter notebooks, e.g. VSCode, RStudio etc.
8.1.3 Resources
Jupyter project’s website has extensive documentations for further learning.
8.2 Installation
Jupyter notebook can be installed independently but it is recommended to install jupyter lab which contains notebook and related dependencies. Link to help page.
<python installation path> -m pip install jupyterlab
Refer to pip usage section (Section 7.4.1).
8.3 Features
- Run code interactively
- Mix rich text, code and results using markdown and code cells
- Export results in different formats like html, pdf, word etc.
8.4 Use cases
Interactive programming for quick trials or learning with annotation
Reproducible Research: quick and easy sharing of ideas/analysis with code and results
8.5 Keyboard Shortcuts
- add cell
- below:
b
- above:
a
- below:
- change cell type
- markdown:
m
- code:
y
- markdown:
cut cell:
x
copy cell:
c
paste cell below:
p
enter/exit cell edit mode:
enter/esc
run cell:
Ctrl + Enter
run cell and move to cell below:
Shift + Enter
8.6 Markdown
Markdown is a markup language which provides simple syntax for text to be converted to different formats. It is used extensively by many tools which try to automate documentation, e.g. quarto, pandoc, github, jupyter notebooks and many more. Each have their own subtle variations, but are very similar as the root is markdown.
Markdown syntax is easy and quick to learn.
8.6.1 Syntax cheat sheet
Description | Syntax |
---|---|
Heading |
|
Bold |
|
Italic |
|
Blockquote |
|
Ordered List |
|
Unordered List |
|
Task List |
|
Code |
|
Horizontal Rule |
|
Link | markdown [title](www.example.com) |
Image |
|
Strikethrough |
|
Subscript |
|
Superscript |
|
Math: inline |
|
Math: display |
|