krz/omaha-metro-blotter

Archive of police activity and ALPR surveillance across the Omaha metro.

clone: git clone https://gitbay.org/krz/omaha-metro-blotter.git

main: notebooks/raw_data_exploration.ipynb · raw

 1{
 2 "cells": [
 3  {
 4   "cell_type": "markdown",
 5   "metadata": {},
 6   "source": [
 7    "# Omaha Incidents"
 8   ]
 9  },
10  {
11   "cell_type": "markdown",
12   "metadata": {},
13   "source": [
14    "## Prerequisites\n",
15    "\n",
16    "You must download the data from the URL below first.\n",
17    "\n",
18    "https://police.cityofomaha.org/crime-information/incident-data-download"
19   ]
20  },
21  {
22   "cell_type": "markdown",
23   "metadata": {},
24   "source": [
25    "## Data Exploration\n",
26    "\n",
27    "Let's explore the data a little bit to see what kind of analysis and visualizations we want to implement."
28   ]
29  },
30  {
31   "cell_type": "code",
32   "execution_count": null,
33   "metadata": {},
34   "outputs": [],
35   "source": [
36    "import pandas as pd"
37   ]
38  },
39  {
40   "cell_type": "code",
41   "execution_count": null,
42   "metadata": {},
43   "outputs": [],
44   "source": [
45    "# import data\n",
46    "df = pd.read_csv(\"../raw_data/Incidents_2015.csv\")\n",
47    "\n",
48    "# test to see what the dataframe looks like\n",
49    "df.head()"
50   ]
51  },
52  {
53   "cell_type": "code",
54   "execution_count": null,
55   "metadata": {},
56   "outputs": [],
57   "source": [
58    "# !pip install \"matplotlib\"\n",
59    "import numpy\n",
60    "import matplotlib\n",
61    "%matplotlib inline"
62   ]
63  },
64  {
65   "cell_type": "code",
66   "execution_count": null,
67   "metadata": {},
68   "outputs": [],
69   "source": [
70    "# test plotting by sorting & plotting top 5 crime categories\n",
71    "s = df.value_counts(subset=[\"Statute/Ordinance Description\"])\n",
72    "t = s.nlargest(5)\n",
73    "t.head()\n",
74    "t.plot(kind=\"bar\", title=\"Top 5 Incident Categories\")"
75   ]
76  }
77 ],
78 "metadata": {
79  "kernelspec": {
80   "display_name": "Python 3 (ipykernel)",
81   "language": "python",
82   "name": "python3"
83  },
84  "language_info": {
85   "codemirror_mode": {
86    "name": "ipython",
87    "version": 3
88   },
89   "file_extension": ".py",
90   "mimetype": "text/x-python",
91   "name": "python",
92   "nbconvert_exporter": "python",
93   "pygments_lexer": "ipython3",
94   "version": "3.11.7"
95  }
96 },
97 "nbformat": 4,
98 "nbformat_minor": 4
99}