Skip to content

Commit

Permalink
add numpy exercises
Browse files Browse the repository at this point in the history
  • Loading branch information
fabridamicelli committed Oct 15, 2024
1 parent 190b31e commit cfea811
Show file tree
Hide file tree
Showing 8 changed files with 146 additions and 42 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# Python Course 🐍
A hands-on introductory course, covering the basics of the Python language with emphasis on scientific and data analysis tasks.
Check it out [here](https://fabridamicelli.github.io/python-course/)!
2 changes: 1 addition & 1 deletion chapters/01_getting_started.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"- Manage virtual environments\n",
"- Install third party libraries\n",
"\n",
"We we'll use here [`uv`](https://docs.astral.sh/uv) which is a high level tool that does all 3 for us."
"We will use here [`uv`](https://docs.astral.sh/uv) which is a high level tool that does all 3 for us."
]
},
{
Expand Down
82 changes: 67 additions & 15 deletions chapters/08_numpy.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,20 @@
"id": "ec86658f-670c-4043-86f7-f2661e486756",
"metadata": {},
"source": [
"Take a look at this intro in [Wes MacKinney's book](https://wesmckinney.com/book/numpy-basics)"
"We will follow here this excellent chapter from [Wes MacKinney's book](https://wesmckinney.com/book/numpy-basics)."
]
},
{
"cell_type": "markdown",
"id": "022c4714-d3cc-4b4f-b755-bade698ffa86",
"metadata": {},
"source": [
"In particular the subtitles:\n",
"\n",
"- Creating ndarray\n",
"- Arithmetic with numpy arrays\n",
"- Basic indexing and slicing\n",
"- Boolean indexing"
]
},
{
Expand Down Expand Up @@ -227,40 +240,79 @@
"For example the `random` submodule exposes several useful functions for stochastic modelling and statistical analysis."
]
},
{
"cell_type": "markdown",
"id": "84c6a8d7-2192-4cf9-adf2-a9f110d5b01f",
"metadata": {},
"source": [
"## Exercises"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "3f77af0d-4398-404f-b379-214220dddbdd",
"id": "123df306-ae3f-4ebf-b283-7e7d9f7705d9",
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,\n",
" 17, 18, 19, 20, 21, 22, 23, 24])"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"#| code-fold: true\n",
"import matplotlib.pyplot as plt"
"arr = np.arange(25)\n",
"arr"
]
},
{
"cell_type": "code",
"execution_count": 14,
"id": "832538ec-db42-4f9f-befc-aee257286bd8",
"execution_count": 6,
"id": "a0840103-6335-4077-afa0-3c843a4d3aec",
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAigAAAGdCAYAAAA44ojeAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjguMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/H5lhTAAAACXBIWXMAAA9hAAAPYQGoP6dpAAAjnUlEQVR4nO3df2xUVf7/8VdbaKXQmaZAOzS0iIhChYLhR5noslVqC1RX1rorykIxBCKZEqG7CDUsiLuxfJAElEVwk43gLl1cjUBgBbbCUtZQEKsERGmEwBYt0yKEmVLDFNr5/rHhfh0oyJQOc6Y8H8lNuPeeufd9M4F5ce6550b5/X6/AAAADBId7gIAAACuRkABAADGIaAAAADjEFAAAIBxCCgAAMA4BBQAAGAcAgoAADAOAQUAABinU7gLaIuWlhbV1tYqISFBUVFR4S4HAADcBL/fr4aGBqWmpio6+sZ9JBEZUGpra5WWlhbuMgAAQBucOnVKvXv3vmGbiAwoCQkJkv53gTabLczVAACAm+H1epWWlmb9jt9IRAaUK7d1bDYbAQUAgAhzM8MzGCQLAACMQ0ABAADGIaAAAADjEFAAAIBxCCgAAMA4BBQAAGAcAgoAADAOAQUAABiHgAIAAIxDQAEAAMYJKqCsXr1amZmZ1hTzTqdT27Zts/ZnZ2crKioqYHnhhRcCjlFTU6P8/HzFx8crOTlZc+fO1eXLl9vnagAAQIcQ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171Ldv33CXg1Zs2rRJv/zlLxUTE2Nta25uVlRUlKKjo+Xz+QL2hQsBJQRqamrk9Xqt9draWuXl5emDDz5QVlaWevfuHcbq0JrvvvtOjzzyiIYNG6a//e1vRvzlhJSVlaWRI0dq5cqVkv536yA9PV1FRUWaP39+mKvDj/n9fs2aNUsbN27U7t271b9//3CXhOtoaGjQf//734Btzz//vAYMGKB58+YZc1uOMSghkJ6eHrDerVs3SVK/fv0IJwb67rvvlJ2drT59+mjZsmU6c+aMtc/hcISxMhQXF6uwsFDDhw/XyJEjtWLFCjU2Nur5558Pd2m4isvlUllZmTZv3qyEhAS53W5Jkt1uV5cuXcJcHX4sISHhmhDStWtXde/e3ZhwIhFQAJWXl+vYsWM6duzYNQGSDsbweuaZZ3TmzBktXLhQbrdbQ4cO1fbt268ZOIvwW716tSQpOzs7YPs777yjqVOn3v6CEPG4xQMAAIzDKEAAAGAcAgoAADAOAQUAABiHgAIAAIxDQAEAAMYhoAAAAOMQUAAAgHEIKAAAwDgEFAAAYBwCCgAAMA4BBQAAGIeAAgAAjPP/AAZQG7ud+DoXAAAAAElFTkSuQmCC",
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
"array([[ 0, 1, 2, 3, 4],\n",
" [ 5, 6, 7, 8, 9],\n",
" [10, 11, 12, 13, 14],\n",
" [15, 16, 17, 18, 19],\n",
" [20, 21, 22, 23, 24]])"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "display_data"
"output_type": "execute_result"
}
],
"source": [
"plt.hist(\n",
" # Draw samples from normal distribution \n",
" np.random.normal(size=10_000),\n",
" bins=100\n",
");"
"arr.reshape(5,5)"
]
},
{
"cell_type": "markdown",
"id": "0db2d668-2302-4288-8a98-1aee524cc44e",
"metadata": {},
"source": [
"1) Reshape `arr` to be a square matrix, call it `arr_sq`.\n",
"2) Extract the values at this coordinates [(0, 3), (2, 4), (3, 2)].\n",
"3) Extract one index operation the elements 1, 4, 9, 11, 21.\n",
"4) Create a boolean mask that will extract the odd numbers from the `arr_sq`.\n",
"5) Find the indices of the even elements off `arr_sq`.\n",
"6) Flatten `arr_sq` into 1 dimension.\n",
"7) Get the third column of `arr_sq`.\n",
"8) Get the second and the fourth rows of `arr_sq`. \n",
"9) Compute the dot product between `arr_sq` and `arr_sq` transposed.\n",
"10) Extract the upper right triangle values (including the diagonal.\n",
"11) Create a square matrix of 25 elements filled only with the value 100 along the main diagonal\n",
"12) Create a square matrix of 25 elements filled only with the value 1 the *counter-diagonal*."
]
}
],
Expand Down
2 changes: 1 addition & 1 deletion docs/01_getting_started.html
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ <h2 data-number="1.1" class="anchored" data-anchor-id="introduction"><span class
<li>Manage virtual environments</li>
<li>Install third party libraries</li>
</ul>
<p>We we’ll use here <a href="https://docs.astral.sh/uv"><code>uv</code></a> which is a high level tool that does all 3 for us.</p>
<p>We will use here <a href="https://docs.astral.sh/uv"><code>uv</code></a> which is a high level tool that does all 3 for us.</p>
</section>
<section id="install-uv" class="level2" data-number="1.2">
<h2 data-number="1.2" class="anchored" data-anchor-id="install-uv"><span class="header-section-number">1.2</span> Install <code>uv</code></h2>
Expand Down
22 changes: 20 additions & 2 deletions docs/081_pandas.html
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,13 @@
<div id="quarto-sidebar-glass" class="quarto-sidebar-collapse-item" data-bs-toggle="collapse" data-bs-target=".quarto-sidebar-collapse-item"></div>
<!-- margin-sidebar -->
<div id="quarto-margin-sidebar" class="sidebar margin-sidebar">

<nav id="TOC" role="doc-toc" class="toc-active">
<h2 id="toc-title">Table of contents</h2>

<ul>
<li><a href="#exercises" id="toc-exercises" class="nav-link active" data-scroll-target="#exercises"><span class="header-section-number">15.1</span> Exercises</a></li>
</ul>
</nav>
</div>
<!-- main -->
<main class="content" id="quarto-document-content">
Expand All @@ -332,13 +338,25 @@ <h1 class="title"><span class="chapter-number">15</span>&nbsp; <span class="chap
</header>


<p>Here’s the introductory <a href="https://wesmckinney.com/book/pandas-basics">chapter of the book</a>, by the original author of the library pandas.</p>
<p>Here’s the introductory <a href="https://wesmckinney.com/book/pandas-basics">chapter of the book</a>, by the original author of the library pandas Wes McKinney. In particular, we’ll look at subtitles:</p>
<ul>
<li><a href="https://wesmckinney.com/book/pandas-basics#pandas_construction">5.1. Introduction to pandas Data Structures</a></li>
<li><a href="https://wesmckinney.com/book/pandas-basics#pandas_series">5.2 Essential Functionality</a></li>
</ul>
<p>These are useful <a href="https://pandas.pydata.org/Pandas_Cheat_Sheet.pdf">cheatsheets</a>.</p>
<p>Check out the pandas getting-started documentation <a href="https://pandas.pydata.org/docs/getting_started/index.html#getting-started">here</a></p>
<p>Here’s short introduction by the very author of the library:</p>
<div class="quarto-video ratio ratio-16x9"><iframe data-external="1" src="https://www.youtube.com/embed/_T8LGqJtuGc" title="" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen=""></iframe></div>
<section id="exercises" class="level2" data-number="15.1">
<h2 data-number="15.1" class="anchored" data-anchor-id="exercises"><span class="header-section-number">15.1</span> Exercises</h2>
<p>Series from dict Missing values</p>
<p>Series from dict Display first 7 elements Display last 7 elements Read in data, assign column names Read in only X rows Compute mean of 1 column Add two columns (numbers) Add two columns (strings) Add a column to existing dataframe Add an indicator column to existing dataframe</p>
<p>Find an interesting dataset, download and explore a bit.</p>
<p>Discard rows with missing values Fill missing values Drop entire rows (by index) Drop entire cols Sort elements (index, values)</p>
<p>Summary metric on specific cols Substract mean of a col from other columns</p>


</section>

</main> <!-- /main -->
<script id="quarto-html-after-body" type="application/javascript">
Expand Down
Loading

0 comments on commit cfea811

Please sign in to comment.