summaryrefslogtreecommitdiff
path: root/tutorials/module_1/jupyter_lab_notebook.ipynb
blob: 20b297c02590221cabd0b6e065c91ea645b59895 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "3895c65a-b923-4c86-94a4-a43dfb09eeab",
   "metadata": {},
   "source": [
    "## Introduction\n",
    "\n",
    "Jupyter Notebooks are often used for data science and scientific\n",
    "computing such as machine learning as the interactive design allow you\n",
    "to experiment easily with your code. For our purpose, we will use\n",
    "Notebooks as it’s a useful tool to learn how to code as well as writing\n",
    "reports.\n",
    "\n",
    "*Note on the difference between Notebook and Lab: Jupyter Notebook\n",
    "offers a simplified, lightweight notebook authoring experience, where\n",
    "as, JupyterLab offers a feature-rich, tabbed multi-notebook editing\n",
    "environment with additional tools like a customizable interface layout\n",
    "and system console*\n",
    "\n",
    "## Setup and Installation\n",
    "\n",
    "Jupyter Notebooks can be installed either from the Anaconda Navigator\n",
    "home page or directly from your Conda terminal.\n",
    "\n",
    "Terminal: `conda install conda-forge::jupyterlab`\n",
    "\n",
    "## Notebook Basics\n",
    "\n",
    "-   Creating a new notebook (`.ipynb`)\n",
    "-   Types of cells:\n",
    "    -   Code\n",
    "    -   Markdown\n",
    "    -   Raw\n",
    "-   Running a cell: `Shift + Enter`\n",
    "-   Adding/removing cells\n",
    "-   Restarting the kernel\n",
    "-   Saving and auto-checkpoints\n",
    "\n",
    "Jupyter Notebooks are files which allows you to combine *Code* and\n",
    "*Markdown* cells in one single document. The code cells, allow you to\n",
    "interactively run python code and print and plot data in your document.\n",
    "If you wish to update or change data your code you can re-run the cell\n",
    "to update the output. The markdown cells allows you to write text,\n",
    "titles and insert images in your documentation using the markup language\n",
    "*Markdown*.\n",
    "\n",
    "## Writing and Running Code\n",
    "\n",
    "-   Python syntax: - `print(\"Hello, world!\")` - Variables and\n",
    "    functions - Loops and conditionals\n",
    "-   Importing libraries: - `import numpy as np` -\n",
    "    `import pandas as pd` - `import matplotlib.pyplot as plt`\n",
    "\n",
    "## Using Markdown\n",
    "\n",
    "-   Headers: `#`, `##`, `###`\n",
    "-   Bullet lists: `- item`\n",
    "-   Numbered lists: `1. item`\n",
    "-   Emphasis: *italic*, **bold**, `monospace`\n",
    "-   LaTeX equations:\n",
    "    -   Inline: `$E = mc^2$`\n",
    "    -   Block: `$$\\int_0^\\infty e^{-x^2} dx = \\frac{\\sqrt{\\pi}}{2}$$`\n",
    "-   Embedding links and images\n",
    "\n",
    "## Interactive Widgets (optional)\n",
    "\n",
    "Install `ipywidgets` from your package manager\n",
    "\n",
    "``` python\n",
    "import ipywidgets as widgets\n",
    "widgets.IntSlider()\n",
    "```\n",
    "\n",
    "Example using interact:\n",
    "\n",
    "``` python\n",
    "from ipywidgets import interact\n",
    "interact(lambda x: x**2, x=5)\n",
    "```\n",
    "\n",
    "## Productivity Tips\n",
    "\n",
    "Here are some keyboard shortcuts to improve your productivity when\n",
    "writing in notebooks.\n",
    "\n",
    "| Key | Action             |\n",
    "|-----|--------------------|\n",
    "| A   | insert cell above  |\n",
    "| B   | insert cell below  |\n",
    "| M   | switch to Markdown |\n",
    "| Y   | switch to code     |\n",
    "\n",
    "Magic commands: - `%timeit`, `%matplotlib inline`, `%%bash` Splitting\n",
    "and merging cells Auto-save behavior\n",
    "\n",
    "## Exporting and Sharing\n",
    "\n",
    "-   File \\> Download As:\n",
    "    -   Notebook (`.ipynb`)\n",
    "    -   HTML\n",
    "    -   PDF (requires LaTeX)\n",
    "    -   Markdown\n",
    "-   Notebooks can be saved and shared via the following services: -\n",
    "    GitHub - nbviewer.org - mybinder.org - JupyterHub"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.13.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}