-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
0 parents
commit a3dded7
Showing
1 changed file
with
423 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,423 @@ | ||
{ | ||
"nbformat": 4, | ||
"nbformat_minor": 0, | ||
"metadata": { | ||
"colab": { | ||
"name": "workshop.ipynb", | ||
"provenance": [], | ||
"collapsed_sections": [] | ||
}, | ||
"kernelspec": { | ||
"name": "python3", | ||
"display_name": "Python 3" | ||
} | ||
}, | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": { | ||
"id": "uqGDNgy9oEDT" | ||
}, | ||
"source": [ | ||
"## **MIDAS Data Science Symposium 2020 Mini-Workshop**\n", | ||
"\n", | ||
"### Introduction to Python for community members, K-12 teachers, and students\n", | ||
"\n", | ||
"### Instructor: Fred Feng (fredfeng@umich.edu)\n", | ||
"\n", | ||
"***" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": { | ||
"id": "_8_63LPSzG0p" | ||
}, | ||
"source": [ | ||
"### **Part 1: Python basics**" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": { | ||
"id": "kHfPzmAgzRsM" | ||
}, | ||
"source": [ | ||
"Variable types" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"metadata": { | ||
"id": "aI8sGUCwmnQv" | ||
}, | ||
"source": [ | ||
"" | ||
], | ||
"execution_count": null, | ||
"outputs": [] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": { | ||
"id": "xurbLU0znz8j" | ||
}, | ||
"source": [ | ||
"### Useful keyboard shortcuts\n", | ||
"- `Ctrl` + `Enter` Run the current cell\n", | ||
"- `Ctrl` + `/` Comment on selected lines" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": { | ||
"id": "8N95yRJ2pUVK" | ||
}, | ||
"source": [ | ||
"### Arithmetic operators\n", | ||
"\n", | ||
"| Python operator | Meaning | Example |\n", | ||
"|----------|---------|---------|\n", | ||
"| + | Addition | `1+2` gives 3 |\n", | ||
"| - | Subtraction | `8-2` gives 6 |\n", | ||
"| * | Multiplication | `2*3` gives 6 |\n", | ||
"| / | Division | `8/4` gives 2 |\n", | ||
"| ** | Exponent | `2**3` gives 8 |" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": { | ||
"id": "USq5mFSvqQ0r" | ||
}, | ||
"source": [ | ||
"### The volume of a sphere with radius $r$ is $\\frac{4}{3}\\pi r^3$. \n", | ||
"### What is the volume of a sphere with a radius of $5$?\n", | ||
"\n", | ||
"<img src=\"https://frfeng.github.io/imse586/sphere.png\" alt=\"sphere\" width=\"150\"/>" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"metadata": { | ||
"id": "xr8UVp2Tnk-w" | ||
}, | ||
"source": [ | ||
"" | ||
], | ||
"execution_count": null, | ||
"outputs": [] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": { | ||
"id": "7c5u1776rMl3" | ||
}, | ||
"source": [ | ||
"### Some useful math functions in the numpy library:\n", | ||
"\n", | ||
"- Square root: `np.sqrt()`\n", | ||
"\n", | ||
"- Exponential function: `np.exp()`\n", | ||
"\n", | ||
"- Natural logarithm: `np.log()`\n", | ||
"\n", | ||
"- Base 10 logarithm: `np.log10()`\n", | ||
"\n", | ||
"For more functions see [here](https://numpy.org/doc/stable/reference/routines.math.html). " | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": { | ||
"id": "MGuECrNcr5fw" | ||
}, | ||
"source": [ | ||
"### Comparison operators\n", | ||
"\n", | ||
"| Math operator | Python operator | Meaning |\n", | ||
"|----------|---------|---------|\n", | ||
"| a > b | a > b | a is greater than b |\n", | ||
"| a < b | a < b | a is less than b |\n", | ||
"| a $\\geq$ b | a >= b | a is greater than or equal to b |\n", | ||
"| a $\\leq$ b | a <= b | a is less than or equal to b |\n", | ||
"| a = b | a == b | a is equal to b |\n", | ||
"| a $\\ne$ b | a != b | a is <font color='red'>not</font> equal to b |\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"metadata": { | ||
"id": "CwUO3p-XrMJp" | ||
}, | ||
"source": [ | ||
"" | ||
], | ||
"execution_count": null, | ||
"outputs": [] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": { | ||
"id": "iE9ikR5NscNq" | ||
}, | ||
"source": [ | ||
"### **`if` statements**: perform different computations depending on conditions.\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"metadata": { | ||
"id": "ElMx5RycuHzX" | ||
}, | ||
"source": [ | ||
"" | ||
], | ||
"execution_count": null, | ||
"outputs": [] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": { | ||
"id": "0FXlvBh7uCjz" | ||
}, | ||
"source": [ | ||
"### **`for` loop**: performing actions for each item in a collection. " | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"metadata": { | ||
"id": "1Dv42H7pu4eM" | ||
}, | ||
"source": [ | ||
"" | ||
], | ||
"execution_count": null, | ||
"outputs": [] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"metadata": { | ||
"id": "xr2V0V7Cu4gk" | ||
}, | ||
"source": [ | ||
"" | ||
], | ||
"execution_count": null, | ||
"outputs": [] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"metadata": { | ||
"id": "fuk7i7nawWwf" | ||
}, | ||
"source": [ | ||
"" | ||
], | ||
"execution_count": null, | ||
"outputs": [] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"metadata": { | ||
"id": "YOziTWtvrMPA" | ||
}, | ||
"source": [ | ||
"fruits = '🍉 🍇 🍋 🍓 🍌 🍍 🥑 🍎 🥝 🍒 🍐'" | ||
], | ||
"execution_count": 1, | ||
"outputs": [] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"metadata": { | ||
"id": "g7gJGeuLsyGZ" | ||
}, | ||
"source": [ | ||
"" | ||
], | ||
"execution_count": 1, | ||
"outputs": [] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": { | ||
"id": "QYclvENY6nzr" | ||
}, | ||
"source": [ | ||
"### Descriptive statistics" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"metadata": { | ||
"id": "F2Hc0AE3syOo" | ||
}, | ||
"source": [ | ||
"" | ||
], | ||
"execution_count": 1, | ||
"outputs": [] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": { | ||
"id": "VGAuGIuB8jV4" | ||
}, | ||
"source": [ | ||
"***\n", | ||
"\n", | ||
"### **Part 2. Data analysis with [pandas](https://pandas.pydata.org/)**" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"metadata": { | ||
"id": "v6IqvXi9LfMs" | ||
}, | ||
"source": [ | ||
"url = 'http://umich.edu/~fredfeng/workshops/college_data.csv'" | ||
], | ||
"execution_count": 2, | ||
"outputs": [] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": { | ||
"id": "a2t4j1nmLhdg" | ||
}, | ||
"source": [ | ||
"### Data description:\n", | ||
"\n", | ||
"This dataset contains a number of variables for over 700 universities and colleges in the U.S.\n", | ||
"\n", | ||
"**Private**: Public/private indicator\n", | ||
"\n", | ||
"**Apps**: Number of applications received\n", | ||
"\n", | ||
"**Accept**: Number of applicants accepted\n", | ||
"\n", | ||
"**Enroll**: Number of new students enrolled\n", | ||
"\n", | ||
"**Top10perc**: New students from top 10% of high school class\n", | ||
"\n", | ||
"**Top25perc**: New students from top 25% of high school class\n", | ||
"\n", | ||
"**F.Undergrad**: Number of full-time undergraduates\n", | ||
"\n", | ||
"**P.Undergrad**: Number of part-time undergraduates\n", | ||
"\n", | ||
"**Outstate**: Out-of-state tuition\n", | ||
"\n", | ||
"**Room.Board**: Room and board costs\n", | ||
"\n", | ||
"**Books**: Estimated book costs\n", | ||
"\n", | ||
"**Personal**: Estimated personal spending\n", | ||
"\n", | ||
"**PhD**: Percent of faculty with Ph.D.’s\n", | ||
"\n", | ||
"**Terminal**: Percent of faculty with terminal degree\n", | ||
"\n", | ||
"**S.F.Ratio**: Student/faculty ratio\n", | ||
"\n", | ||
"**perc.alumni**: Percent of alumni who donate\n", | ||
"\n", | ||
"**Expend**: Instructional expenditure per student\n", | ||
"\n", | ||
"**Grad.Rate**: Graduation rate" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"metadata": { | ||
"id": "gi3q0PAS57X-" | ||
}, | ||
"source": [ | ||
"" | ||
], | ||
"execution_count": 2, | ||
"outputs": [] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"metadata": { | ||
"id": "LbDHmE6vSrSd" | ||
}, | ||
"source": [ | ||
"" | ||
], | ||
"execution_count": 2, | ||
"outputs": [] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": { | ||
"id": "ZbK2mQSNZYFA" | ||
}, | ||
"source": [ | ||
"" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": { | ||
"id": "vYibYHroSygq" | ||
}, | ||
"source": [ | ||
"***\n", | ||
"\n", | ||
"### **Part 3. Data visualization with [matplotlib](https://matplotlib.org/gallery/index.html)**" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"metadata": { | ||
"id": "rakcRS4GSrWH" | ||
}, | ||
"source": [ | ||
"" | ||
], | ||
"execution_count": 2, | ||
"outputs": [] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"metadata": { | ||
"id": "Z4rI7OTDT1CC" | ||
}, | ||
"source": [ | ||
"" | ||
], | ||
"execution_count": 2, | ||
"outputs": [] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"metadata": { | ||
"id": "tNKprknqaM_r" | ||
}, | ||
"source": [ | ||
"" | ||
], | ||
"execution_count": null, | ||
"outputs": [] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": { | ||
"id": "lh4lLpoJZOj0" | ||
}, | ||
"source": [ | ||
"### **Further resources**\n", | ||
"\n", | ||
"- [A longer version (4-hours) of this workshop on YouTube](https://www.youtube.com/watch?v=7IsFmtvBOyc)\n", | ||
"\n", | ||
"- [Install Jupyter Notebook on your local machine](https://frfeng.github.io/imse586/Anaconda_Installation.pdf)\n", | ||
"\n", | ||
"- [Data Wrangling with pandas Cheat Sheet](https://pandas.pydata.org/Pandas_Cheat_Sheet.pdf)\n" | ||
] | ||
} | ||
] | ||
} |