Making reports with

29-Oct-2024

What is Jupyter?

  • An open source project for interactive data science and computing
  • Allows you to document, edit and run code directly in your browser

Notebook basics

  • Runs as a local web server
  • Load/save/manage notebooks from the menu

Jupyter lab

The next-generation interface for Jupyter

  • Similar to an integrated development environments (IDE).
  • Tab views, Code consoles, Show output in a separate tab, Live rendering of edits etc.
  • The jupyter lab interface can run Jupyter notebooks in the main work area

Using Jupyter notebooks

  • Document your work in markdown…
**Penguin data analysis**

Here we will investigate the [Penguin dataset](https://github.com/allisonhorst/palmerpenguins).

---

The species included in this set are:

 - _Adelie_
 - _Chinstrap_
 - _Gentoo_

Using Jupyter notebooks

  • Document your work in markdown…and have it rendered automatically.

Penguin data analysis

Here we will investigate the Penguin dataset.


The species included in this set are:

  • Adelie
  • Chinstrap
  • Gentoo

Using Jupyter notebooks

  • Document your work in markdown…and have it rendered automatically.
  • Execute code directly from the browser, with results attached to the code which generated them.
import seaborn as sns

data = sns.load_dataset("penguins")
data.groupby("species").mean(numeric_only=True)
bill_length_mm bill_depth_mm flipper_length_mm body_mass_g
species
Adelie 38.791391 18.346358 189.953642 3700.662252
Chinstrap 48.833824 18.420588 195.823529 3733.088235
Gentoo 47.504878 14.982114 217.186992 5076.016260

Using Jupyter notebooks

  • Document your work in markdown…and have it rendered automatically.
  • Execute code directly from the browser, with results attached to the code which generated them.
  • Mix and match languages in addition to python.

R

%%R
print(paste(Sys.Date(), ": Hello World", sep=""))
[1] "2024-10-29: Hello World"

Using Jupyter notebooks

  • Document your work in markdown…and have it rendered automatically.
  • Execute code directly from the browser, with results attached to the code which generated them.
  • Mix and match languages in addition to python.

R

%%R
print(paste(Sys.Date(), ": Hello World", sep=""))
[1] "2024-10-29: Hello World"

bash

%%bash
echo "$(date): Hello World!"
Tue Oct 29 08:01:00 UTC 2024: Hello World!

Using Jupyter notebooks

  • Document your work in markdown…and have it rendered automatically
  • Execute code directly from the browser, with results attached to the code which generated them
  • Mix and match languages in addition to python.
  • Generate plots directly in the browser and/or save to file.
sns.set_context("paper",
                rc={"axes.labelsize":6})
ax = sns.pairplot(
    data,
    hue="species",
    height=1,
    plot_kws=dict(s=20, linewidth=0.5),
    diag_kws=dict(linewidth=0.5))

Use cases

  • Lab notebook
  • Data exploration
  • Code development
  • Reports
  • Interactive dashboards
  • and more…

Sharing notebooks

  • Put the notebook on GitHub/Bitbucket and it will be rendered there
  • Export to one of many different formats, e.g. HTML, PDF, code, slides etc.
  • Paste a link to any Jupyter notebook nbviewer.jupyter.org and it will be rendered for you.
  • Or generate interactive notebooks using Binder

For the tutorial

  • jupyter lab - will give you the updated and more advanced Jupyter lab interface
  • jupyter notebook - will give you the Classic notebook interface

Questions?