From a3dded792be9cedffe5d4d251a7040e7df5917e7 Mon Sep 17 00:00:00 2001 From: Fred Feng Date: Tue, 10 Nov 2020 04:18:05 -0500 Subject: [PATCH] Add files via upload --- workshop.ipynb | 423 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 423 insertions(+) create mode 100644 workshop.ipynb diff --git a/workshop.ipynb b/workshop.ipynb new file mode 100644 index 0000000..9c8201f --- /dev/null +++ b/workshop.ipynb @@ -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", + "\"sphere\"" + ] + }, + { + "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 not 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" + ] + } + ] +} \ No newline at end of file