diff --git a/lecture_4.ipynb b/lecture_4.ipynb index 296a5577..1841e1d9 100644 --- a/lecture_4.ipynb +++ b/lecture_4.ipynb @@ -70,7 +70,50 @@ } }, "source": [ - "As an example, we'll look at the frequency of 311 requests:\n", + "Simple time series: The population data." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import pandas as pd\n", + "\n", + "districts = pd.read_csv('https://storage.googleapis.com/python-public-policy/data/311_community_districts.csv.zip')\n", + "districts.head()" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "slideshow": { + "slide_type": "subslide" + } + }, + "source": [ + "Helpful function for looking at changes over time: [`pct_change()`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.pct_change.html)." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "discticts.pct_change(axis='columns')" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "slideshow": { + "slide_type": "slide" + } + }, + "source": [ + "Next, we'll look at the frequency of 311 requests:\n", "\n", "- Over time\n", "- By day of the week\n", @@ -106,7 +149,6 @@ }, "outputs": [], "source": [ - "import pandas as pd\n", "import plotly.express as px\n", "\n", "# boilerplate for allowing PDF export\n",