Skip to content

Commit

Permalink
add intro to jupyter to preparation (#91)
Browse files Browse the repository at this point in the history
* add intro to jupyter to preparation

* update schedule

* update quarto links

* Update _quarto.yml
  • Loading branch information
jelletreep committed Nov 21, 2023
1 parent 7c991dd commit 19cdf9f
Show file tree
Hide file tree
Showing 4 changed files with 206 additions and 98 deletions.
9 changes: 6 additions & 3 deletions book/_quarto.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
project:
type: book
output-dir: ../docs

output-dir: ./docs

book:
title: "Introduction to Python & Data"
Expand Down Expand Up @@ -34,8 +35,10 @@ book:
- solutions/afternoon_exercises_solutions.ipynb
- what-next.qmd
- references.qmd
repo-url: https://github.com/UtrechtUniversity/workshop-introduction-to-python
repo-actions: [edit]
repo-url: https://github.com/UtrechtUniversity/workshop-introduction-to-python/
repo-subdir: book
issue-url: https://github.com/UtrechtUniversity/workshop-introduction-to-python/issues/new
repo-actions: [edit, issue, source]
sidebar:
logo: images/python-hex-logo.png

Expand Down
6 changes: 3 additions & 3 deletions book/schedule.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
| 9:00 | Walk-in, tech support |
| 9:30 | Introductions |
| 10:00 | Python Fundamentals Chapters 1-3: _Exercises 0-3_ |
| 11:25 | Recap & Questions |
| **11:30** | **Coffee break** |
| 11:45 | Python Fundamentals Chapters 4-5: _Exercises 4-9_ |
| 10:55 | Recap & Questions |
| **11:00** | **Coffee break** |
| 11:15 | Python Fundamentals Chapters 4-5: _Exercises 4-9_ |
| 12:40 | Recap & Questions |
| **12:45** | **Lunch break** |
| 13:30 | Data Science with Pandas Chapters 6-7: _Exercises 0-4_ |
Expand Down
92 changes: 0 additions & 92 deletions course_materials/empty_notebook_for_coding_along.ipynb

This file was deleted.

197 changes: 197 additions & 0 deletions course_materials/preparation.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,197 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "6be8c60c-486a-49ec-860d-e8dc361928ad",
"metadata": {},
"source": [
"# Preparation\n",
"\n",
"Use this notebook to prepare for the workshop and for coding along during the lectures.\n",
"Use the dedicated exercises notebooks `morning_exercises.ipynb` and `afternoon_exercises.ipynb` for the exercises parts."
]
},
{
"cell_type": "markdown",
"id": "c239edb5",
"metadata": {},
"source": [
"## Preparation step 1: Introduction to Jupyter notebooks"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"A Jupyter Notebook is:\n",
"\n",
"> an open-source web application that allows you to create and share documents that contain live code, equations, visualizations and narrative text. ([jupyter.org](https://jupyter.org/))\n",
"\n",
"A Notebook consists of one or more \"cells\" in which you can put text and code. The text you are reading right now is placed in a `Markdown` cell. Click somewhere on this text _once_ and verify this at the top of this page.\n",
"\n",
"The next cell is a `Code` cell. The current notebook uses a Python interpreter (check the top right corner to verify, it will display `Python 3 (ipykernel)`) which means it expects Python code and can only interpret Python code. Different setups are also possible (e.g. with an `R` or `Julia` interpreter). \n",
"\n",
"Click `Python 3 (ipykernel)`, and change the kernel to `geo-kernel`. This is a different Python interpreter where we preinstalled all Python packages that we need for this workshop.\n",
"\n",
"Select the following cell, verify at the top of this window if it displays `Code` instead of `Markdown`, and either click the 'play'-button above or press `<ctrl>-<enter>` simultaneously to run the Python code."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"print('Hello world!')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Check that the output is printed below the cell!\n",
"\n",
"Markdown cells can contain a wide variety of things:\n",
"\n",
"- Headers\n",
"- Lists\n",
"- Lengthy paragraphs\n",
"- Tables\n",
"- Images\n",
"- Equations\n",
"\n",
"See the examples below, and double click this cell to see how to create these things.\n",
"\n",
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Facilisis sed odio morbi quis commodo odio aenean sed adipiscing. Cras fermentum odio eu feugiat pretium. At urna condimentum mattis pellentesque id nibh tortor. Blandit libero volutpat sed cras ornare arcu dui vivamus arcu. Iaculis eu non diam phasellus vestibulum lorem sed risus. Purus sit amet luctus venenatis. Egestas fringilla phasellus faucibus scelerisque eleifend donec. Quam id leo in vitae. Eget aliquet nibh praesent tristique magna. Bibendum neque egestas congue quisque egestas diam in. Diam sit amet nisl suscipit. Tellus pellentesque eu tincidunt tortor aliquam nulla. Nisl nisi scelerisque eu ultrices vitae auctor eu augue ut. Metus vulputate eu scelerisque felis imperdiet. Tristique risus nec feugiat in fermentum posuere urna nec. Egestas congue quisque egestas diam in arcu cursus. Mi sit amet mauris commodo quis imperdiet.\n",
"\n",
"| column 1 | Column 2|\n",
"|---|---|\n",
"| 0 | 1 | \n",
"| 4 | 5.5| \n",
"| 5 | 3 | \n",
"\n",
"**The Cauchy-Schwarz Inequality**\n",
"$$\\left( \\sum_{k=1}^n a_k b_k \\right)^2 \\leq \\left( \\sum_{k=1}^n a_k^2 \\right) \\left( \\sum_{k=1}^n b_k^2 \\right)$$\n",
"\n",
"<img src=\"https://www.uu.nl/sites/default/files/styles/image_1600xn/public/ubd-afsluiting-logo-pay-off.png?mt=1626952634&itok=yu-iR1Fy\" width=\"400\" height=\"400\">\n",
"\n",
"Follow this [link](https://www.markdownguide.org/basic-syntax/) for more markdown formatting examples"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Click this cell, and hit `B` on your keyboard to create a new cell below. You can also click the `+` sign at the top of this screen. You can ignore the new cell and continue reading..."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Code cells can contain all of your Python code. You can put many lines of code into one cell, or create many cells with only a few lines of code. You can define variables and functions in one cell and call them in another cell. However, you need to be aware that the order in which you run the cells matters. Try to run the cells below to understand what we mean:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"print(a)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"a = 6"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"print(a)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"A finished notebook should contain python code cells that can be run from the top to the bottom of the notebook. When your notebook becomes more complex, typically what happens is that because you have been running and changing and rerunning code cells while developing, the logic of your python code from top to bottom breaks. To prevent this (or at least get notified in an early stage) it is good practice to regularly restart the Python 'kernel' and run all the cells from top to bottom (or up to the selected cell). Click the Kernel tab at the top of this window and verify if you see these options, and click `Restart Kernel and Run up to Selected Cell`."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Here we end the brief introduction to Jupyter notebooks. If you are interested, check out the documentation at the [jupyter website](https://docs.jupyter.org/en/latest/)"
]
},
{
"cell_type": "markdown",
"id": "2d5cbbaf",
"metadata": {},
"source": [
"## Preparation step 2: Test installation\n",
"\n",
"Run the cell below to check if your all installations are is complete, if you see some numbers and the message: `No errors! Ready to code!`, all the relevant libraries are correctly installed and you are ready for the workshop!\n",
"If this is not the case, contact us (see the welcome email for instructions)."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "d8e35e29-a355-45e7-a693-624f0ee80b2b",
"metadata": {},
"outputs": [],
"source": [
"from platform import python_version\n",
"\n",
"import pandas as pd\n",
"import matplotlib\n",
"import numpy as np\n",
"\n",
"print(python_version())\n",
"print(pd.__version__)\n",
"print(matplotlib.__version__)\n",
"print(np.__version__)\n",
"print(\"No errors! Ready to code!\")"
]
},
{
"cell_type": "markdown",
"id": "b9d2ce0a-75fb-48c4-8524-b4cb8e4ffeff",
"metadata": {},
"source": [
"# Chapter 2"
]
}
],
"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.10.8"
}
},
"nbformat": 4,
"nbformat_minor": 5
}

0 comments on commit 19cdf9f

Please sign in to comment.