{"metadata": {"kernelspec": {"display_name": "sd212", "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.11.7"}}, "nbformat": 4, "nbformat_minor": 2, "cells": [{"cell_type": "markdown", "metadata": {}, "source": ["## [name] Type your name on the next line\n", "\n", "\n"]}, {"cell_type": "markdown", "metadata": {}, "source": ["# SD212 Lab 01: Crimes\n", "\n", "## Instructions\n", "\n", "Just like for any jupyter notebook to work, you have to first\n", "hit \"Select Kernel\", then go to \"Python Environments\", and you should\n", "see your sd212 mamba environment to select.\n", "\n", "Each question from the lab has its own markdown cell below.\n", "\n", "For questions that have a direct answer like a number or a\n", "paragraph of explanation, fill in your answer in that same\n", "markdown cell and don't put anything else there.\n", "\n", "Then **add a Python (code) cell afterwards** to show how you\n", "computed the answer. We aren't specifying exactly what your code\n", "needs to print out, but when we run your code we should see the answer\n", "(easily) in the output of your code cell.\n", "\n", "That is, each direct answer like a number should show up twice:\n", "first directly typed into the markdown cell under the question header\n", "like `# [Q10]`, second as the output of running the Python code cell\n", "that follows it.\n", "\n", "For questions that ask you to generate a graph or image, then of course\n", "the graph should also be displayed, after the question header, from running\n", "the notebook.\n", "\n", "After you submit, we will test your code by running the entire\n", "notebook. To test it yourself and make sure you didn't get anything\n", "out of order, just do:\n", "\n", "1.  Clear All Outputs\n", "2.  Restart\n", "3.  Run All\n", "\n", "And all of the computations and graphs should be re-generated.\n", "\n", "Good luck and have fun!"]}, {"cell_type": "code", "metadata": {}, "outputs": [], "execution_count": null, "source": ["# Do your library imports and data reading in this initial code cell.\n", "# It will take a few seconds, but you should only need to run this\n", "# cell once. That's a big advantage of notebooks!\n"]}, {"cell_type": "markdown", "metadata": {}, "source": ["# Section 3: Exploring the data"]}, {"cell_type": "markdown", "metadata": {}, "source": ["## [Q1]\n", "> How many total rows are in this dataset (not counting the header row)?\n", "\n", "\n", "\n"]}, {"cell_type": "markdown", "metadata": {}, "source": ["## [Q2]\n", "> How many car thefts occurred in the dataset?\n", "\n", "> (Do not include car jackings, just regular thefts.)\n", "\n", "\n", "\n"]}, {"cell_type": "markdown", "metadata": {}, "source": ["## [Q3]\n", "> There is only one neighborhood which had over 100 homicides.\n", "> What is this neighborhood called?\n", "\n", "\n", "\n"]}, {"cell_type": "markdown", "metadata": {}, "source": ["## [Q4]\n", "> Which *district* is that neighborhood in?\n", "\n", "\n", "\n"]}, {"cell_type": "markdown", "metadata": {}, "source": ["## [Q5]\n", "> There is a column for gender. Do you think this is the gender of the\n", "> victim or the assailant? Explain how you figured this out.\n", "\n", "> (Hint: Use the data! Some types of crimes disproportionately impact\n", "> one gender or another.)\n", "\n", "\n", "\n"]}, {"cell_type": "markdown", "metadata": {}, "source": ["# Section 4: Getting the dates right"]}, {"cell_type": "markdown", "metadata": {}, "source": ["## [Q6]\n", "> What is the **year** (only) of the first date in `crimes.csv` that\n", "> pandas could not convert to a datetime object?\n", "\n", "\n", "\n"]}, {"cell_type": "markdown", "metadata": {}, "source": ["## [Q7]\n", "> How many crimes were committed in 2015?\n", "\n", "\n", "\n"]}, {"cell_type": "markdown", "metadata": {}, "source": ["## [Q8]\n", "> How many crimes were committed between March 14 and December 14,\n", "> 2020 (including both those dates)?\n", "\n", "> (Hint 1: You can create normal `datetime` objects from the\n", "> `datetime` python library to compare against.\n", "\n", "\n", "\n"]}, {"cell_type": "markdown", "metadata": {}, "source": ["## [Q9]\n", "> How many *robberies* occurred on Fridays which were the 13th day of\n", "> the month?\n", "\n", "\n", "\n"]}, {"cell_type": "markdown", "metadata": {}, "source": ["## [Q10]\n", "> Which hour of the day had the least number of \"common assaults\" occur?\n", "\n", "\n", "\n"]}, {"cell_type": "markdown", "metadata": {}, "source": ["## [Q11]\n", "> What were the four most common types of crimes in the seven years\n", "> from 2016 to 2022 (inclusive)?\n", "\n", "\n", "\n"]}, {"cell_type": "markdown", "metadata": {}, "source": ["# Section 5: Graphing Crime Data"]}, {"cell_type": "markdown", "metadata": {}, "source": ["## [Q12]\n", "> Create your histogram so it displays in the notebook.\n", "\n", "> When plotting, use options `width=1000, height=600`\n", "> to give a consistent size for your instructor to grade.\n", "\n", "> Click on the little camera icon on the graph to\n", "> **save your graph as a file called `years.png`\n", "\n", "\n", "\n"]}, {"cell_type": "markdown", "metadata": {}, "source": ["## [Q13]\n", "> Which year in the plotted range had the highest number of larcenies?\n", "\n", "\n", "\n"]}, {"cell_type": "markdown", "metadata": {}, "source": ["## [Q14]\n", "> Considering the years most affected by the COVID pandemic, what\n", "> kind(s) of crime decreased during those years, and what kind(s) did\n", "> not decrease as much?\n", "> Give a brief explanation of why that might be the case.\n", "\n", "\n", "\n"]}, {"cell_type": "markdown", "metadata": {}, "source": ["# Section 6: Days of the week (OPTIONAL)"]}, {"cell_type": "markdown", "metadata": {}, "source": ["## [Q15]\n", "> Create your histogram\n", "> (with width 1000 and height 600 like before).\n", "\n", "> Save it as a file `days.png`\n", "\n", "\n", "\n"]}, {"cell_type": "markdown", "metadata": {}, "source": ["## [Q16]\n", "> Which neighborhood sees the most crimes during weekdays (M-F)?\n", "\n", "\n", "\n"]}, {"cell_type": "markdown", "metadata": {}, "source": ["## [Q17]\n", "> In most districts the crime level stays the same or goes down on the\n", "> weekends (Friday--Sunday). But one neighborhood sees a slight but\n", "> noticeable *increase* in crime on weekends. Which neighborhood, and\n", "> why?\n", "\n", "> (Hint: Try to find a map of the city and look at what is located\n", "> in this district.)\n", "\n", "\n", "\n"]}]}