{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Pittsburgh Juvenile Arrests Data Analysis" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Importing libraries and initializing settings" ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "" ], "text/vnd.plotly.v1+html": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "import pandas as pd # pandas is a library for data manipulation and analysis\n", "pd.options.mode.chained_assignment = None # This will turn off an annoying warning\n", "\n", "import plotly # plotly is a library for interactive data visualization\n", "import plotly.graph_objs as go # this let's me make graphs with plotly more easily\n", "plotly.offline.init_notebook_mode() # this let's the graphs appear offline in the jupyter notebook" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "(21311, 17)\n" ] }, { "data": { "text/html": [ "
\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
_idPKCCRAGEGENDERRACEARRESTTIMEARRESTLOCATIONOFFENSESINCIDENTLOCATIONINCIDENTNEIGHBORHOODINCIDENTZONEINCIDENTTRACTCOUNCIL_DISTRICTPUBLIC_WORKS_DIVISIONXY
0540319813571702444826.0MW2017-02-09T01:04:0020 Block Bailey AV Pittsburgh, PA 152115505 Public Drunkenness / 5503(a)(4) DISORDERL...20 Block Bailey AV Pittsburgh, PA 15211Mount Washington31807.03.05.0-80.00446140.427049
1540419813581702134631.0FW2017-02-04T01:30:00N CHARLES ST & PERRYSVILLE AV Pittsburgh, PA 1...3925 Receiving Stolen Property. / 1543 Driving...N CHARLES ST & PERRYSVILLE AV Pittsburgh, PA 1...Perry South12615.06.01.0-80.00859840.471006
2540519813591702135122.0MB2017-02-04T01:51:002200 Block Somers DR Pittsburgh, PA 1521913(a)(16) Possession of Controlled Substance /...2200 Block Somers DR Pittsburgh, PA 15219Bedford Dwellings2509.06.03.0-79.97568740.449422
31010219872511712077833.0FB2017-06-29T20:04:001400 Block 5th AV Pittsburgh, PA 1521913(a)(16) Possession of Controlled Substance /...1400 Block 5th AV Pittsburgh, PA 15219Bluff2103.06.03.0-79.98631040.438370
41010319872551616466725.0MB2017-07-02T02:00:00900 Block 2nd AV Pittsburgh, PA 152193921 Theft by Unlawful Taking or Disposition.20 Block Stanwix ST Pittsburgh, PA 15222Central Business District2201.06.06.0-80.00517840.438667
\n", "
" ], "text/plain": [ " _id PK CCR AGE GENDER RACE ARRESTTIME \\\n", "0 5403 1981357 17024448 26.0 M W 2017-02-09T01:04:00 \n", "1 5404 1981358 17021346 31.0 F W 2017-02-04T01:30:00 \n", "2 5405 1981359 17021351 22.0 M B 2017-02-04T01:51:00 \n", "3 10102 1987251 17120778 33.0 F B 2017-06-29T20:04:00 \n", "4 10103 1987255 16164667 25.0 M B 2017-07-02T02:00:00 \n", "\n", " ARRESTLOCATION \\\n", "0 20 Block Bailey AV Pittsburgh, PA 15211 \n", "1 N CHARLES ST & PERRYSVILLE AV Pittsburgh, PA 1... \n", "2 2200 Block Somers DR Pittsburgh, PA 15219 \n", "3 1400 Block 5th AV Pittsburgh, PA 15219 \n", "4 900 Block 2nd AV Pittsburgh, PA 15219 \n", "\n", " OFFENSES \\\n", "0 5505 Public Drunkenness / 5503(a)(4) DISORDERL... \n", "1 3925 Receiving Stolen Property. / 1543 Driving... \n", "2 13(a)(16) Possession of Controlled Substance /... \n", "3 13(a)(16) Possession of Controlled Substance /... \n", "4 3921 Theft by Unlawful Taking or Disposition. \n", "\n", " INCIDENTLOCATION \\\n", "0 20 Block Bailey AV Pittsburgh, PA 15211 \n", "1 N CHARLES ST & PERRYSVILLE AV Pittsburgh, PA 1... \n", "2 2200 Block Somers DR Pittsburgh, PA 15219 \n", "3 1400 Block 5th AV Pittsburgh, PA 15219 \n", "4 20 Block Stanwix ST Pittsburgh, PA 15222 \n", "\n", " INCIDENTNEIGHBORHOOD INCIDENTZONE INCIDENTTRACT COUNCIL_DISTRICT \\\n", "0 Mount Washington 3 1807.0 3.0 \n", "1 Perry South 1 2615.0 6.0 \n", "2 Bedford Dwellings 2 509.0 6.0 \n", "3 Bluff 2 103.0 6.0 \n", "4 Central Business District 2 201.0 6.0 \n", "\n", " PUBLIC_WORKS_DIVISION X Y \n", "0 5.0 -80.004461 40.427049 \n", "1 1.0 -80.008598 40.471006 \n", "2 3.0 -79.975687 40.449422 \n", "3 3.0 -79.986310 40.438370 \n", "4 6.0 -80.005178 40.438667 " ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df = pd.read_csv(\"pgh_arrest_data.csv\") # loading in the data\n", "print(df.shape) # seeing how many rows and columns the data has\n", "df.head() # previewing the first five rows of the dataset " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Data cleaning / processing" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "21104" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df = df[(df.AGE.values<120)&(df.AGE.values>0)] # FILTER TO REMOVE CASES WHERE AGE IS MISSSING OR TOO LOW/HIGH TO BE CORRECT\n", "len(df) # compare with previous number of rows to see how many cases were removed" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
_idPKCCRAGEGENDERRACEARRESTTIMEARRESTLOCATIONOFFENSESINCIDENTLOCATIONINCIDENTNEIGHBORHOODINCIDENTZONEINCIDENTTRACTCOUNCIL_DISTRICTPUBLIC_WORKS_DIVISIONXY
11894173461996555524778110.0MB2005-12-21T09:00:0040 Block COWAN ST PITTSBURGH, PA 15211912 Possession of Weapon on School Property.40 Block COWAN ST PITTSBURGH, PA 15211NaN3NaN2.05.0-80.01018440.427336
175169461995957621605629.0MB2006-11-02T09:00:00900 Block second AV Pittsburgh, PA 152193921 Theft by Unlawful Taking or Disposition. ...900 Block CRESSWELL ST PITTSBURGH, PANaN3NaN3.03.0-79.97620440.408768
1364495041986575703431421.0FB2007-02-21T13:30:00100 Block Rhine PL Pittsburgh, PA 152122701 Simple Assault.100 Block RHINE PL PITTSBURGH, PA 15212Spring Hill-City View12620.01.01.0-79.99409940.466786
571102891987517710227240.0MB2007-05-22T16:42:00Tioga ST & Rosedale ST Pittsburgh, PA 1520813(a)(16) Possession of Controlled Substance /...TIOGA ST & ROSEDALE ST PITTSBURGH, PA 15208Homewood South51303.09.02.0-79.88683340.450037
266376661984153823458314.0FB2008-10-04T12:25:00200 Block Greenfield AV Pittsburgh, PA 152072701 Simple Assault.200 Block GREENFIELD AV PITTSBURGH, PAGreenfield41516.05.03.0-79.94980840.425719
6060898119859461100367716.0MB2011-01-07T13:00:003300 Block CENTRE AV PITTSBURGH, PA 152192701(a)(1) Simple Assault - Intent., Know., Re...500 Block N Highland AV Pittsburgh, PA 15206East Liberty51113.08.02.0-79.92496140.453011
171901972119995421111512222.0MW2011-06-23T02:30:00E Carson ST & S 22nd ST Pittsburgh, PA 152034903 False Swearing. / 5505 Public Drunkenness...E Carson ST & S 22nd ST Pittsburgh, PA 15203South Side Flats31702.03.03.0-79.97463940.428413
76952126120014551219273617.0MB2012-10-03T13:48:00600 Block 1st AV Pittsburgh, PA 152192702 Aggravated Assault.200 Block S Negley AV Pittsburgh, PA 15206East Liberty51115.0NaNNaN0.0000000.000000
169962099120011351300416317.0MW2013-02-27T01:21:00800 Block E Warrington AV Pittsburgh, PA 152102711 Domestic Violence / 2701(a)(1) Simple Ass...300 Block Merrimac ST Pittsburgh, PA 15211Mount Washington31903.02.05.0-80.01391940.431633
119732029720003161402512724.0MB2014-02-09T01:22:002200 Block E Carson ST Pittsburgh, PA 152032702 Aggravated Assault. / 5104 Resisting Arre...2200 Block E Carson ST Pittsburgh, PA 15203South Side Flats31609.03.03.0-79.97445440.428227
96401784719971801408628427.0FW2014-05-10T04:05:004000 Block Cabinet WY Pittsburgh, PA 152242701 Simple Assault. / 5503(a)(3) DISORDERLY C...4000 Block Cabinet WY Pittsburgh, PA 15224Bloomfield5903.07.02.0-79.95755540.463864
58831218619898231420445723.0MW2014-10-13T03:47:00Copperfield AV & Mt Joseph ST Pittsburgh, PA 1...2706 Terroristic Threats. / 5104 Resisting Arr...Copperfield AV & Mt Joseph ST Pittsburgh, PA 1...Carrick32901.04.03.0-79.98972540.395400
18311462019803921422772820.0FB2014-11-16T03:42:003200 Block Middletown RD Pittsburgh, PA 15204903 Criminal Conspiracy. / 2702 Aggravated Ass...3200 Block Middletown RD Pittsburgh, PA 15204Windgap62807.02.05.0-80.06674140.450950
18312462119803931422772830.0MB2014-11-16T03:42:003200 Block Middletown RD Pittsburgh, PA 15204903 Criminal Conspiracy. / 2702 Aggravated Ass...3200 Block Middletown RD Pittsburgh, PA 15204Windgap62807.02.05.0-80.06674140.450950
2762461919803911422772827.0FB2014-11-16T03:42:003200 Block Middletown RD Pittsburgh, PA 15204903 Criminal Conspiracy. / 2702 Aggravated Ass...3200 Block Middletown RD Pittsburgh, PA 15204Windgap62807.02.05.0-80.06674140.450950
115761899119986151417943133.0FB2015-02-19T14:00:00200 Block Allegheny River BL Pittsburgh, PA 151472709(a)(1) Harassment by Physical Contact, or ...5300 Block Broad ST Pittsburgh, PA 15224Garfield51017.09.02.0-79.93820340.465812
1025163319754351509559125.0MB2015-05-29T07:55:00Gladys AV & Crane AV Pittsburgh, PA 152163111 Obedience to Traffic-Control Devices. / 3...Gladys AV & Crane AV Pittsburgh, PA 15216Beechview61916.04.05.0-80.02424540.416917
118021546719940191512024216.0MB2015-07-02T19:19:00600 Block 1st AV Pittsburgh, PA 152192701 Simple Assault.400 Block N Taylor AV Pittsburgh, PA 15212Central North Side12206.01.01.0-80.01129840.456933
2622370619792771520484622.0MW2015-11-04T19:45:00600 Block 1st AV Pittsburgh, PA 152196310.1 Selling Liquor to Minors / 601.04 (c) (...3800 Block Bates ST Pittsburgh, PA 15213Central Oakland4406.03.03.0-79.95334740.438601
2680370719792781520484621.0MW2015-11-04T19:45:00600 Block 1st AV Pittsburgh, PA 152196310.1 Selling Liquor to Minors / 601.04 (c) (...3800 Block Bates ST Pittsburgh, PA 15213Central Oakland4406.03.03.0-79.95334740.438601
14592467219804441602442524.0FB2016-02-12T21:00:00600 Block First AV Pittsburgh, PA 152192701(a)(1) Simple Assault - Intent., Know., Re...1100 Block McKinney LANE Pittsburgh, PA 15205Ridgemont62016.02.05.0-80.03503440.423529
1765063219753851602921831.0MW2016-02-17T15:25:00800 Block Concord ST Pittsburgh, PA 1521213(a)(16) Possession of Controlled Substance /...800 Block Concord ST Pittsburgh, PA 15212East Allegheny12304.01.01.0-79.99792440.457564
5272333819787901600455231.0FO2016-03-03T09:45:00600 Block 1st AV Pittsburgh, PA 152199015 Failure To Appear/Arrest on Attachment Order600 Block Liberty AV Pittsburgh, PA 15222Central Business District2201.06.06.0-80.00162040.441773
20536124519760291606005622.0MW2016-04-04T00:45:00S 15th ST & E Carson ST Pittsburgh, PA 152032702 Aggravated Assault. / 2706 Terroristic Th...S 15th ST & E Carson ST Pittsburgh, PA 15203South Side Flats31702.03.03.0-79.98342540.428815
12247466619804381606290836.0MW2016-04-08T02:34:00Boyd ST & Diamond ST Pittsburgh, PA 1521913(a)(32) Paraphernalia - Use or PossessionBoyd ST & Diamond ST Pittsburgh, PA 15219Bluff2103.06.06.0-79.99329340.438656
18572466419804361605414660.0MW2016-04-10T09:00:00600 Block 1st AV Pittsburgh, PA 152195104 Resisting Arrest or Other Law Enforcement...Forbes AV & Armstrong TUN Pittsburgh, PA 15219Bluff2103.06.06.0-79.99205240.437971
18585466519804371605899654.0MB2016-04-12T01:30:00900 Block 2nd AV Pittsburgh, PA 152192705 Recklessy Endangering Another Person. / 2...1600 Block Forbes AV Pittsburgh, PA 15219Bluff2103.06.03.0-79.98387040.437377
15079466719804391606185120.0MB2016-04-12T19:55:00600 Block First AV Pittsburgh, PA 152193924 Theft of Property Lost, Mislaid or Delive...400 Block Wood ST Pittsburgh, PA 15219Central Business District2201.06.06.0-80.00122340.439375
12248467019804421606682131.0MW2016-04-13T20:00:001000 Block Fort Duquesne BL Pittsburgh, PA 152222702 Aggravated Assault. / 5104 Resisting Arre...1000 Block Fort Duquesne BL Pittsburgh, PA 15222Central Business District2201.06.06.0-79.99524540.445511
14454466819804401606682129.0MW2016-04-13T20:00:001000 Block Fort Duquesne BL Pittsburgh, PA 152222702 Aggravated Assault. / 5104 Resisting Arre...1000 Block Fort Duquesne BL Pittsburgh, PA 15222Central Business District2201.06.06.0-79.99524540.445511
......................................................
106062107420012391724952946.0MB2018-06-12T07:03:001600 Block Penn AV Pittsburgh, PA 152225101 Obstructing Admin. of Law / 5105 Hinderi...1600 Block Penn AV Pittsburgh, PA 15222Strip District2203.07.06.0-79.98747240.448835
156432107720012421803541449.0MW2018-06-12T07:30:00400 Block JANICE DR Pittsburgh, PA 152353502 Burglary. / 3921 Theft by Unlawful Taking...1700 Block Jancey ST Pittsburgh, PA 15206Morningside51014.07.02.0-79.92759040.484790
172082108120012461807650749.0MW2018-06-12T07:30:00400 Block JANICE DR Pittsburgh, PA 152353502 Burglary. / 3921 Theft by Unlawful Taking...1700 Block Jancey ST Pittsburgh, PA 15206Morningside51014.07.02.0-79.92759040.484790
156772108520012501808525549.0MW2018-06-12T07:30:00400 Block JANICE DR Pittsburgh, PA 152353921 Theft by Unlawful Taking or Disposition. ...1500 Block Hawthorne ST Pittsburgh, PA 15201Stanton Heights51018.07.02.0-79.93427240.484916
70002108020012451804722621.0MB2018-06-12T10:20:00600 Block 1ST AV Pittsburgh, PA 152199015 Failure To Appear/Arrest on Attachment Order200 Block Fifth AV Pittsburgh, PA 15222Central Business District2201.06.06.0-80.00207740.441236
19832108220012471807866534.0FW2018-06-12T11:10:001400 Block prospect RD Pittsburgh, PA 152273921 Theft by Unlawful Taking or Disposition. ...100 Block N Bellefield AV Pittsburgh, PA 15213North Oakland4404.08.03.0-79.95183540.447152
159422116020013411810611166.0MB2018-06-12T11:15:00900 Block 2ND AV Pittsburgh, PA 1521913(a)(16) Possession of Controlled Substance /...1500 Block Monterey ST Pittsburgh, PA 15212Central North Side12503.06.01.0-80.01341240.457302
157342109920012641810118850.0FB2018-06-12T11:45:00600 Block 1st AV Pittsburgh, PA 152192701 Simple Assault.4800 Block Friendship AV Pittsburgh, PA 15224Bloomfield5809.07.02.0-79.94626340.462132
157202109520012601809941238.0MB2018-06-12T14:05:00900 Block 2nd AV Pittsburgh, PA 152193925 Receiving Stolen Property. / 6105(a)(1) P...60 Block E Amanda AV Pittsburgh, PA 15210Knoxville33001.03.05.0-79.98812140.419383
183492107320012381714418237.0MW2018-06-12T16:45:00900 Block 2nd AV Pittsburgh, PA 152192706 Terroristic Threats. / 2718(a)(1) Strangu...300 Block Aidyl AV Pittsburgh, PA 15226Brookline61919.04.05.0-80.02756040.395325
170262107620012411802374827.0MW2018-06-12T17:52:00Olympia ST & Piermont ST Pittsburgh, PA 152113921(a) Theft by Unlawful Taking or Dispositio...5700 Block Beacon ST Pittsburgh, PA 15217Squirrel Hill South41413.05.03.0-79.92471340.434526
45612107520012401801603727.0MW2018-06-12T17:52:00Olympia ST & Piermont ST Pittsburgh, PA 152112706 Terroristic Threats.5700 Block Beacon ST Pittsburgh, PA 15217Squirrel Hill South41413.05.03.0-79.92471340.434526
70622109820012631810031054.0MB2018-06-12T19:30:00Forbes AV & Stanwinx ST Pittsburgh, PA 152223701 Robbery.500 Block Francis ST Pittsburgh, PA 15219Middle Hill2501.06.03.0-79.96749440.447140
170442109720012621810005954.0MB2018-06-12T19:30:00Forbes AV & Stanwix ST Pittsburgh, PA 152222701 Simple Assault. / 3701 Robbery.4000 Block Brighton RD Pittsburgh, PA 15212Brighton Heights12701.01.01.0-80.04085240.487917
170272107820012431804478542.0FW2018-06-12T20:11:00E Elizabeth ST & Gertrude ST Pittsburgh, PA 152079015 Failure To Appear/Arrest on Attachment Order2nd AV & Mansion ST Pittsburgh, PA 15207Hazelwood41515.05.03.0-79.94231340.403720
172502108720012521809036323.0MB2018-06-12T22:47:00900 Block 2nd AV Pittsburgh, PA 152199015 Failure To Appear/Arrest on Attachment Order3400 Block Gass AV Pittsburgh, PA 15212Brighton Heights12703.01.01.0-80.03467240.477074
157022108620012511808614825.0FW2018-06-13T02:06:00600 Block 1st AV Pittsburgh, PA 152195104 Resisting Arrest or Other Law Enforcement...4000 Block Butler ST Pittsburgh, PA 15201Central Lawrenceville2902.07.02.0-79.96168140.468701
24662111120012761810221628.0MB2018-06-13T08:25:00600 Block 1ST AV Pittsburgh, PA 152192706 Terroristic Threats. / 2709(a) Harassment.300 Block Beltzhoover AV Pittsburgh, PA 15210Beltzhoover31809.03.05.0-79.99751540.419880
156452108320012481808096630.0MW2018-06-13T09:00:00Zone 23127 Indecent Exposure.Zone 2NaN2NaNNaNNaNNaNNaN
157592110620012711804666422.0MB2018-06-13T11:45:00900 Block 2nd AV Pittsburgh, PA 152191543 Driving While Operating Privilege is Susp...1300 Block Silverton AV Pittsburgh, PA 15206Lincoln-Lemington-Belmar51202.0NaNNaN0.0000000.000000
106562110720012721805866040.0MU2018-06-13T13:10:00600 Block 1ST AV Pittsburgh, PA 152193926(a)(1) Theft of Services; Cable, Gas, Taxi...500 Block N Craig ST Pittsburgh, PA 15213North Oakland4507.06.03.0-79.95440540.456098
157642110520012701723475720.0MB2018-06-13T16:40:00900 Block 2nd AV Pittsburgh, PA 152199015 Failure To Appear/Arrest on Attachment Order100 Block N Negley AV Pittsburgh, PA 15206Garfield51114.07.02.0-79.92473140.474284
156492108420012491808352918.0MB2018-06-13T19:10:00600 Block First AV Pittsburgh, PA 152199015 Failure To Appear/Arrest on Attachment Order100 Block Rhine PL Pittsburgh, PA 15212Spring Hill-City View12620.01.01.0-79.99204240.465360
157192109220012571809533025.0MB2018-06-13T19:29:00700 Block Grand AV Wilkinsburgh, PA 1522113(a)(32) Paraphernalia - Use or Possession / ...1400 Block Washington BL Pittsburgh, PA 15206Highland Park51106.09.02.0-79.90860840.470381
157142109120012561809533056.0MB2018-06-13T19:29:00Bennett ST & Tokay ST Pittsburgh, PA 152216105(a)(1) Persons not to possess, use, manufa...1400 Block Washington BL Pittsburgh, PA 15206Highland Park51106.09.02.0-79.90860840.470381
73792117720013581810664131.0MB2018-06-13T19:56:00600 Block 1st AV Pittsburgh, PA 152192705 Recklessy Endangering Another Person. / 1...300 Block 5th AV Pittsburgh, PA 15222Central Business District2201.06.06.0-80.00029040.440526
24032110420012691716697538.0FW2018-06-13T22:20:00900 Block 2nd AV Pittsburgh, PA 152199015 Failure To Appear/Arrest on Attachment Order200 Block S Winebiddle ST Pittsburgh, PA 15224Bloomfield5809.07.02.0-79.94325240.464531
157652110820012731806553324.0FB2018-06-13T23:00:00900 Block 2nd AV Pittsburgh, PA 152192701 Simple Assault. / 3502 Burglary. / 3921 T...7400 Block Monticello ST Pittsburgh, PA 15208Homewood North51302.09.02.0-79.89101640.458322
106572110920012741807447960.0MB2018-06-14T02:19:00900 Block 2nd AV Pittsburgh, PA 152199015 Failure To Appear/Arrest on Attachment Order1400 Block Adams ST Pittsburgh, PA 15233Manchester12107.06.01.0-80.02799940.458723
157762111020012751807477746.0FB2018-06-14T02:50:00900 Block 2nd AV Pittsburgh, PA 152192701 Simple Assault. / 2706 Terroristic Threats.2500 Block Brighton RD Pittsburgh, PA 15212Marshall-Shadeland12704.06.01.0-80.02479440.467289
\n", "

21104 rows × 17 columns

\n", "
" ], "text/plain": [ " _id PK CCR AGE GENDER RACE ARRESTTIME \\\n", "11894 17346 1996555 5247781 10.0 M B 2005-12-21T09:00:00 \n", "175 16946 1995957 6216056 29.0 M B 2006-11-02T09:00:00 \n", "13644 9504 1986575 7034314 21.0 F B 2007-02-21T13:30:00 \n", "571 10289 1987517 7102272 40.0 M B 2007-05-22T16:42:00 \n", "2663 7666 1984153 8234583 14.0 F B 2008-10-04T12:25:00 \n", "6060 8981 1985946 11003677 16.0 M B 2011-01-07T13:00:00 \n", "17190 19721 1999542 11115122 22.0 M W 2011-06-23T02:30:00 \n", "7695 21261 2001455 12192736 17.0 M B 2012-10-03T13:48:00 \n", "16996 20991 2001135 13004163 17.0 M W 2013-02-27T01:21:00 \n", "11973 20297 2000316 14025127 24.0 M B 2014-02-09T01:22:00 \n", "9640 17847 1997180 14086284 27.0 F W 2014-05-10T04:05:00 \n", "5883 12186 1989823 14204457 23.0 M W 2014-10-13T03:47:00 \n", "18311 4620 1980392 14227728 20.0 F B 2014-11-16T03:42:00 \n", "18312 4621 1980393 14227728 30.0 M B 2014-11-16T03:42:00 \n", "2762 4619 1980391 14227728 27.0 F B 2014-11-16T03:42:00 \n", "11576 18991 1998615 14179431 33.0 F B 2015-02-19T14:00:00 \n", "10251 633 1975435 15095591 25.0 M B 2015-05-29T07:55:00 \n", "11802 15467 1994019 15120242 16.0 M B 2015-07-02T19:19:00 \n", "2622 3706 1979277 15204846 22.0 M W 2015-11-04T19:45:00 \n", "2680 3707 1979278 15204846 21.0 M W 2015-11-04T19:45:00 \n", "14592 4672 1980444 16024425 24.0 F B 2016-02-12T21:00:00 \n", "17650 632 1975385 16029218 31.0 M W 2016-02-17T15:25:00 \n", "5272 3338 1978790 16004552 31.0 F O 2016-03-03T09:45:00 \n", "20536 1245 1976029 16060056 22.0 M W 2016-04-04T00:45:00 \n", "12247 4666 1980438 16062908 36.0 M W 2016-04-08T02:34:00 \n", "18572 4664 1980436 16054146 60.0 M W 2016-04-10T09:00:00 \n", "18585 4665 1980437 16058996 54.0 M B 2016-04-12T01:30:00 \n", "15079 4667 1980439 16061851 20.0 M B 2016-04-12T19:55:00 \n", "12248 4670 1980442 16066821 31.0 M W 2016-04-13T20:00:00 \n", "14454 4668 1980440 16066821 29.0 M W 2016-04-13T20:00:00 \n", "... ... ... ... ... ... ... ... \n", "10606 21074 2001239 17249529 46.0 M B 2018-06-12T07:03:00 \n", "15643 21077 2001242 18035414 49.0 M W 2018-06-12T07:30:00 \n", "17208 21081 2001246 18076507 49.0 M W 2018-06-12T07:30:00 \n", "15677 21085 2001250 18085255 49.0 M W 2018-06-12T07:30:00 \n", "7000 21080 2001245 18047226 21.0 M B 2018-06-12T10:20:00 \n", "1983 21082 2001247 18078665 34.0 F W 2018-06-12T11:10:00 \n", "15942 21160 2001341 18106111 66.0 M B 2018-06-12T11:15:00 \n", "15734 21099 2001264 18101188 50.0 F B 2018-06-12T11:45:00 \n", "15720 21095 2001260 18099412 38.0 M B 2018-06-12T14:05:00 \n", "18349 21073 2001238 17144182 37.0 M W 2018-06-12T16:45:00 \n", "17026 21076 2001241 18023748 27.0 M W 2018-06-12T17:52:00 \n", "4561 21075 2001240 18016037 27.0 M W 2018-06-12T17:52:00 \n", "7062 21098 2001263 18100310 54.0 M B 2018-06-12T19:30:00 \n", "17044 21097 2001262 18100059 54.0 M B 2018-06-12T19:30:00 \n", "17027 21078 2001243 18044785 42.0 F W 2018-06-12T20:11:00 \n", "17250 21087 2001252 18090363 23.0 M B 2018-06-12T22:47:00 \n", "15702 21086 2001251 18086148 25.0 F W 2018-06-13T02:06:00 \n", "2466 21111 2001276 18102216 28.0 M B 2018-06-13T08:25:00 \n", "15645 21083 2001248 18080966 30.0 M W 2018-06-13T09:00:00 \n", "15759 21106 2001271 18046664 22.0 M B 2018-06-13T11:45:00 \n", "10656 21107 2001272 18058660 40.0 M U 2018-06-13T13:10:00 \n", "15764 21105 2001270 17234757 20.0 M B 2018-06-13T16:40:00 \n", "15649 21084 2001249 18083529 18.0 M B 2018-06-13T19:10:00 \n", "15719 21092 2001257 18095330 25.0 M B 2018-06-13T19:29:00 \n", "15714 21091 2001256 18095330 56.0 M B 2018-06-13T19:29:00 \n", "7379 21177 2001358 18106641 31.0 M B 2018-06-13T19:56:00 \n", "2403 21104 2001269 17166975 38.0 F W 2018-06-13T22:20:00 \n", "15765 21108 2001273 18065533 24.0 F B 2018-06-13T23:00:00 \n", "10657 21109 2001274 18074479 60.0 M B 2018-06-14T02:19:00 \n", "15776 21110 2001275 18074777 46.0 F B 2018-06-14T02:50:00 \n", "\n", " ARRESTLOCATION \\\n", "11894 40 Block COWAN ST PITTSBURGH, PA 15211 \n", "175 900 Block second AV Pittsburgh, PA 15219 \n", "13644 100 Block Rhine PL Pittsburgh, PA 15212 \n", "571 Tioga ST & Rosedale ST Pittsburgh, PA 15208 \n", "2663 200 Block Greenfield AV Pittsburgh, PA 15207 \n", "6060 3300 Block CENTRE AV PITTSBURGH, PA 15219 \n", "17190 E Carson ST & S 22nd ST Pittsburgh, PA 15203 \n", "7695 600 Block 1st AV Pittsburgh, PA 15219 \n", "16996 800 Block E Warrington AV Pittsburgh, PA 15210 \n", "11973 2200 Block E Carson ST Pittsburgh, PA 15203 \n", "9640 4000 Block Cabinet WY Pittsburgh, PA 15224 \n", "5883 Copperfield AV & Mt Joseph ST Pittsburgh, PA 1... \n", "18311 3200 Block Middletown RD Pittsburgh, PA 15204 \n", "18312 3200 Block Middletown RD Pittsburgh, PA 15204 \n", "2762 3200 Block Middletown RD Pittsburgh, PA 15204 \n", "11576 200 Block Allegheny River BL Pittsburgh, PA 15147 \n", "10251 Gladys AV & Crane AV Pittsburgh, PA 15216 \n", "11802 600 Block 1st AV Pittsburgh, PA 15219 \n", "2622 600 Block 1st AV Pittsburgh, PA 15219 \n", "2680 600 Block 1st AV Pittsburgh, PA 15219 \n", "14592 600 Block First AV Pittsburgh, PA 15219 \n", "17650 800 Block Concord ST Pittsburgh, PA 15212 \n", "5272 600 Block 1st AV Pittsburgh, PA 15219 \n", "20536 S 15th ST & E Carson ST Pittsburgh, PA 15203 \n", "12247 Boyd ST & Diamond ST Pittsburgh, PA 15219 \n", "18572 600 Block 1st AV Pittsburgh, PA 15219 \n", "18585 900 Block 2nd AV Pittsburgh, PA 15219 \n", "15079 600 Block First AV Pittsburgh, PA 15219 \n", "12248 1000 Block Fort Duquesne BL Pittsburgh, PA 15222 \n", "14454 1000 Block Fort Duquesne BL Pittsburgh, PA 15222 \n", "... ... \n", "10606 1600 Block Penn AV Pittsburgh, PA 15222 \n", "15643 400 Block JANICE DR Pittsburgh, PA 15235 \n", "17208 400 Block JANICE DR Pittsburgh, PA 15235 \n", "15677 400 Block JANICE DR Pittsburgh, PA 15235 \n", "7000 600 Block 1ST AV Pittsburgh, PA 15219 \n", "1983 1400 Block prospect RD Pittsburgh, PA 15227 \n", "15942 900 Block 2ND AV Pittsburgh, PA 15219 \n", "15734 600 Block 1st AV Pittsburgh, PA 15219 \n", "15720 900 Block 2nd AV Pittsburgh, PA 15219 \n", "18349 900 Block 2nd AV Pittsburgh, PA 15219 \n", "17026 Olympia ST & Piermont ST Pittsburgh, PA 15211 \n", "4561 Olympia ST & Piermont ST Pittsburgh, PA 15211 \n", "7062 Forbes AV & Stanwinx ST Pittsburgh, PA 15222 \n", "17044 Forbes AV & Stanwix ST Pittsburgh, PA 15222 \n", "17027 E Elizabeth ST & Gertrude ST Pittsburgh, PA 15207 \n", "17250 900 Block 2nd AV Pittsburgh, PA 15219 \n", "15702 600 Block 1st AV Pittsburgh, PA 15219 \n", "2466 600 Block 1ST AV Pittsburgh, PA 15219 \n", "15645 Zone 2 \n", "15759 900 Block 2nd AV Pittsburgh, PA 15219 \n", "10656 600 Block 1ST AV Pittsburgh, PA 15219 \n", "15764 900 Block 2nd AV Pittsburgh, PA 15219 \n", "15649 600 Block First AV Pittsburgh, PA 15219 \n", "15719 700 Block Grand AV Wilkinsburgh, PA 15221 \n", "15714 Bennett ST & Tokay ST Pittsburgh, PA 15221 \n", "7379 600 Block 1st AV Pittsburgh, PA 15219 \n", "2403 900 Block 2nd AV Pittsburgh, PA 15219 \n", "15765 900 Block 2nd AV Pittsburgh, PA 15219 \n", "10657 900 Block 2nd AV Pittsburgh, PA 15219 \n", "15776 900 Block 2nd AV Pittsburgh, PA 15219 \n", "\n", " OFFENSES \\\n", "11894 912 Possession of Weapon on School Property. \n", "175 3921 Theft by Unlawful Taking or Disposition. ... \n", "13644 2701 Simple Assault. \n", "571 13(a)(16) Possession of Controlled Substance /... \n", "2663 2701 Simple Assault. \n", "6060 2701(a)(1) Simple Assault - Intent., Know., Re... \n", "17190 4903 False Swearing. / 5505 Public Drunkenness... \n", "7695 2702 Aggravated Assault. \n", "16996 2711 Domestic Violence / 2701(a)(1) Simple Ass... \n", "11973 2702 Aggravated Assault. / 5104 Resisting Arre... \n", "9640 2701 Simple Assault. / 5503(a)(3) DISORDERLY C... \n", "5883 2706 Terroristic Threats. / 5104 Resisting Arr... \n", "18311 903 Criminal Conspiracy. / 2702 Aggravated Ass... \n", "18312 903 Criminal Conspiracy. / 2702 Aggravated Ass... \n", "2762 903 Criminal Conspiracy. / 2702 Aggravated Ass... \n", "11576 2709(a)(1) Harassment by Physical Contact, or ... \n", "10251 3111 Obedience to Traffic-Control Devices. / 3... \n", "11802 2701 Simple Assault. \n", "2622 6310.1 Selling Liquor to Minors / 601.04 (c) (... \n", "2680 6310.1 Selling Liquor to Minors / 601.04 (c) (... \n", "14592 2701(a)(1) Simple Assault - Intent., Know., Re... \n", "17650 13(a)(16) Possession of Controlled Substance /... \n", "5272 9015 Failure To Appear/Arrest on Attachment Order \n", "20536 2702 Aggravated Assault. / 2706 Terroristic Th... \n", "12247 13(a)(32) Paraphernalia - Use or Possession \n", "18572 5104 Resisting Arrest or Other Law Enforcement... \n", "18585 2705 Recklessy Endangering Another Person. / 2... \n", "15079 3924 Theft of Property Lost, Mislaid or Delive... \n", "12248 2702 Aggravated Assault. / 5104 Resisting Arre... \n", "14454 2702 Aggravated Assault. / 5104 Resisting Arre... \n", "... ... \n", "10606 5101 Obstructing Admin. of Law / 5105 Hinderi... \n", "15643 3502 Burglary. / 3921 Theft by Unlawful Taking... \n", "17208 3502 Burglary. / 3921 Theft by Unlawful Taking... \n", "15677 3921 Theft by Unlawful Taking or Disposition. ... \n", "7000 9015 Failure To Appear/Arrest on Attachment Order \n", "1983 3921 Theft by Unlawful Taking or Disposition. ... \n", "15942 13(a)(16) Possession of Controlled Substance /... \n", "15734 2701 Simple Assault. \n", "15720 3925 Receiving Stolen Property. / 6105(a)(1) P... \n", "18349 2706 Terroristic Threats. / 2718(a)(1) Strangu... \n", "17026 3921(a) Theft by Unlawful Taking or Dispositio... \n", "4561 2706 Terroristic Threats. \n", "7062 3701 Robbery. \n", "17044 2701 Simple Assault. / 3701 Robbery. \n", "17027 9015 Failure To Appear/Arrest on Attachment Order \n", "17250 9015 Failure To Appear/Arrest on Attachment Order \n", "15702 5104 Resisting Arrest or Other Law Enforcement... \n", "2466 2706 Terroristic Threats. / 2709(a) Harassment. \n", "15645 3127 Indecent Exposure. \n", "15759 1543 Driving While Operating Privilege is Susp... \n", "10656 3926(a)(1) Theft of Services; Cable, Gas, Taxi... \n", "15764 9015 Failure To Appear/Arrest on Attachment Order \n", "15649 9015 Failure To Appear/Arrest on Attachment Order \n", "15719 13(a)(32) Paraphernalia - Use or Possession / ... \n", "15714 6105(a)(1) Persons not to possess, use, manufa... \n", "7379 2705 Recklessy Endangering Another Person. / 1... \n", "2403 9015 Failure To Appear/Arrest on Attachment Order \n", "15765 2701 Simple Assault. / 3502 Burglary. / 3921 T... \n", "10657 9015 Failure To Appear/Arrest on Attachment Order \n", "15776 2701 Simple Assault. / 2706 Terroristic Threats. \n", "\n", " INCIDENTLOCATION \\\n", "11894 40 Block COWAN ST PITTSBURGH, PA 15211 \n", "175 900 Block CRESSWELL ST PITTSBURGH, PA \n", "13644 100 Block RHINE PL PITTSBURGH, PA 15212 \n", "571 TIOGA ST & ROSEDALE ST PITTSBURGH, PA 15208 \n", "2663 200 Block GREENFIELD AV PITTSBURGH, PA \n", "6060 500 Block N Highland AV Pittsburgh, PA 15206 \n", "17190 E Carson ST & S 22nd ST Pittsburgh, PA 15203 \n", "7695 200 Block S Negley AV Pittsburgh, PA 15206 \n", "16996 300 Block Merrimac ST Pittsburgh, PA 15211 \n", "11973 2200 Block E Carson ST Pittsburgh, PA 15203 \n", "9640 4000 Block Cabinet WY Pittsburgh, PA 15224 \n", "5883 Copperfield AV & Mt Joseph ST Pittsburgh, PA 1... \n", "18311 3200 Block Middletown RD Pittsburgh, PA 15204 \n", "18312 3200 Block Middletown RD Pittsburgh, PA 15204 \n", "2762 3200 Block Middletown RD Pittsburgh, PA 15204 \n", "11576 5300 Block Broad ST Pittsburgh, PA 15224 \n", "10251 Gladys AV & Crane AV Pittsburgh, PA 15216 \n", "11802 400 Block N Taylor AV Pittsburgh, PA 15212 \n", "2622 3800 Block Bates ST Pittsburgh, PA 15213 \n", "2680 3800 Block Bates ST Pittsburgh, PA 15213 \n", "14592 1100 Block McKinney LANE Pittsburgh, PA 15205 \n", "17650 800 Block Concord ST Pittsburgh, PA 15212 \n", "5272 600 Block Liberty AV Pittsburgh, PA 15222 \n", "20536 S 15th ST & E Carson ST Pittsburgh, PA 15203 \n", "12247 Boyd ST & Diamond ST Pittsburgh, PA 15219 \n", "18572 Forbes AV & Armstrong TUN Pittsburgh, PA 15219 \n", "18585 1600 Block Forbes AV Pittsburgh, PA 15219 \n", "15079 400 Block Wood ST Pittsburgh, PA 15219 \n", "12248 1000 Block Fort Duquesne BL Pittsburgh, PA 15222 \n", "14454 1000 Block Fort Duquesne BL Pittsburgh, PA 15222 \n", "... ... \n", "10606 1600 Block Penn AV Pittsburgh, PA 15222 \n", "15643 1700 Block Jancey ST Pittsburgh, PA 15206 \n", "17208 1700 Block Jancey ST Pittsburgh, PA 15206 \n", "15677 1500 Block Hawthorne ST Pittsburgh, PA 15201 \n", "7000 200 Block Fifth AV Pittsburgh, PA 15222 \n", "1983 100 Block N Bellefield AV Pittsburgh, PA 15213 \n", "15942 1500 Block Monterey ST Pittsburgh, PA 15212 \n", "15734 4800 Block Friendship AV Pittsburgh, PA 15224 \n", "15720 60 Block E Amanda AV Pittsburgh, PA 15210 \n", "18349 300 Block Aidyl AV Pittsburgh, PA 15226 \n", "17026 5700 Block Beacon ST Pittsburgh, PA 15217 \n", "4561 5700 Block Beacon ST Pittsburgh, PA 15217 \n", "7062 500 Block Francis ST Pittsburgh, PA 15219 \n", "17044 4000 Block Brighton RD Pittsburgh, PA 15212 \n", "17027 2nd AV & Mansion ST Pittsburgh, PA 15207 \n", "17250 3400 Block Gass AV Pittsburgh, PA 15212 \n", "15702 4000 Block Butler ST Pittsburgh, PA 15201 \n", "2466 300 Block Beltzhoover AV Pittsburgh, PA 15210 \n", "15645 Zone 2 \n", "15759 1300 Block Silverton AV Pittsburgh, PA 15206 \n", "10656 500 Block N Craig ST Pittsburgh, PA 15213 \n", "15764 100 Block N Negley AV Pittsburgh, PA 15206 \n", "15649 100 Block Rhine PL Pittsburgh, PA 15212 \n", "15719 1400 Block Washington BL Pittsburgh, PA 15206 \n", "15714 1400 Block Washington BL Pittsburgh, PA 15206 \n", "7379 300 Block 5th AV Pittsburgh, PA 15222 \n", "2403 200 Block S Winebiddle ST Pittsburgh, PA 15224 \n", "15765 7400 Block Monticello ST Pittsburgh, PA 15208 \n", "10657 1400 Block Adams ST Pittsburgh, PA 15233 \n", "15776 2500 Block Brighton RD Pittsburgh, PA 15212 \n", "\n", " INCIDENTNEIGHBORHOOD INCIDENTZONE INCIDENTTRACT \\\n", "11894 NaN 3 NaN \n", "175 NaN 3 NaN \n", "13644 Spring Hill-City View 1 2620.0 \n", "571 Homewood South 5 1303.0 \n", "2663 Greenfield 4 1516.0 \n", "6060 East Liberty 5 1113.0 \n", "17190 South Side Flats 3 1702.0 \n", "7695 East Liberty 5 1115.0 \n", "16996 Mount Washington 3 1903.0 \n", "11973 South Side Flats 3 1609.0 \n", "9640 Bloomfield 5 903.0 \n", "5883 Carrick 3 2901.0 \n", "18311 Windgap 6 2807.0 \n", "18312 Windgap 6 2807.0 \n", "2762 Windgap 6 2807.0 \n", "11576 Garfield 5 1017.0 \n", "10251 Beechview 6 1916.0 \n", "11802 Central North Side 1 2206.0 \n", "2622 Central Oakland 4 406.0 \n", "2680 Central Oakland 4 406.0 \n", "14592 Ridgemont 6 2016.0 \n", "17650 East Allegheny 1 2304.0 \n", "5272 Central Business District 2 201.0 \n", "20536 South Side Flats 3 1702.0 \n", "12247 Bluff 2 103.0 \n", "18572 Bluff 2 103.0 \n", "18585 Bluff 2 103.0 \n", "15079 Central Business District 2 201.0 \n", "12248 Central Business District 2 201.0 \n", "14454 Central Business District 2 201.0 \n", "... ... ... ... \n", "10606 Strip District 2 203.0 \n", "15643 Morningside 5 1014.0 \n", "17208 Morningside 5 1014.0 \n", "15677 Stanton Heights 5 1018.0 \n", "7000 Central Business District 2 201.0 \n", "1983 North Oakland 4 404.0 \n", "15942 Central North Side 1 2503.0 \n", "15734 Bloomfield 5 809.0 \n", "15720 Knoxville 3 3001.0 \n", "18349 Brookline 6 1919.0 \n", "17026 Squirrel Hill South 4 1413.0 \n", "4561 Squirrel Hill South 4 1413.0 \n", "7062 Middle Hill 2 501.0 \n", "17044 Brighton Heights 1 2701.0 \n", "17027 Hazelwood 4 1515.0 \n", "17250 Brighton Heights 1 2703.0 \n", "15702 Central Lawrenceville 2 902.0 \n", "2466 Beltzhoover 3 1809.0 \n", "15645 NaN 2 NaN \n", "15759 Lincoln-Lemington-Belmar 5 1202.0 \n", "10656 North Oakland 4 507.0 \n", "15764 Garfield 5 1114.0 \n", "15649 Spring Hill-City View 1 2620.0 \n", "15719 Highland Park 5 1106.0 \n", "15714 Highland Park 5 1106.0 \n", "7379 Central Business District 2 201.0 \n", "2403 Bloomfield 5 809.0 \n", "15765 Homewood North 5 1302.0 \n", "10657 Manchester 1 2107.0 \n", "15776 Marshall-Shadeland 1 2704.0 \n", "\n", " COUNCIL_DISTRICT PUBLIC_WORKS_DIVISION X Y \n", "11894 2.0 5.0 -80.010184 40.427336 \n", "175 3.0 3.0 -79.976204 40.408768 \n", "13644 1.0 1.0 -79.994099 40.466786 \n", "571 9.0 2.0 -79.886833 40.450037 \n", "2663 5.0 3.0 -79.949808 40.425719 \n", "6060 8.0 2.0 -79.924961 40.453011 \n", "17190 3.0 3.0 -79.974639 40.428413 \n", "7695 NaN NaN 0.000000 0.000000 \n", "16996 2.0 5.0 -80.013919 40.431633 \n", "11973 3.0 3.0 -79.974454 40.428227 \n", "9640 7.0 2.0 -79.957555 40.463864 \n", "5883 4.0 3.0 -79.989725 40.395400 \n", "18311 2.0 5.0 -80.066741 40.450950 \n", "18312 2.0 5.0 -80.066741 40.450950 \n", "2762 2.0 5.0 -80.066741 40.450950 \n", "11576 9.0 2.0 -79.938203 40.465812 \n", "10251 4.0 5.0 -80.024245 40.416917 \n", "11802 1.0 1.0 -80.011298 40.456933 \n", "2622 3.0 3.0 -79.953347 40.438601 \n", "2680 3.0 3.0 -79.953347 40.438601 \n", "14592 2.0 5.0 -80.035034 40.423529 \n", "17650 1.0 1.0 -79.997924 40.457564 \n", "5272 6.0 6.0 -80.001620 40.441773 \n", "20536 3.0 3.0 -79.983425 40.428815 \n", "12247 6.0 6.0 -79.993293 40.438656 \n", "18572 6.0 6.0 -79.992052 40.437971 \n", "18585 6.0 3.0 -79.983870 40.437377 \n", "15079 6.0 6.0 -80.001223 40.439375 \n", "12248 6.0 6.0 -79.995245 40.445511 \n", "14454 6.0 6.0 -79.995245 40.445511 \n", "... ... ... ... ... \n", "10606 7.0 6.0 -79.987472 40.448835 \n", "15643 7.0 2.0 -79.927590 40.484790 \n", "17208 7.0 2.0 -79.927590 40.484790 \n", "15677 7.0 2.0 -79.934272 40.484916 \n", "7000 6.0 6.0 -80.002077 40.441236 \n", "1983 8.0 3.0 -79.951835 40.447152 \n", "15942 6.0 1.0 -80.013412 40.457302 \n", "15734 7.0 2.0 -79.946263 40.462132 \n", "15720 3.0 5.0 -79.988121 40.419383 \n", "18349 4.0 5.0 -80.027560 40.395325 \n", "17026 5.0 3.0 -79.924713 40.434526 \n", "4561 5.0 3.0 -79.924713 40.434526 \n", "7062 6.0 3.0 -79.967494 40.447140 \n", "17044 1.0 1.0 -80.040852 40.487917 \n", "17027 5.0 3.0 -79.942313 40.403720 \n", "17250 1.0 1.0 -80.034672 40.477074 \n", "15702 7.0 2.0 -79.961681 40.468701 \n", "2466 3.0 5.0 -79.997515 40.419880 \n", "15645 NaN NaN NaN NaN \n", "15759 NaN NaN 0.000000 0.000000 \n", "10656 6.0 3.0 -79.954405 40.456098 \n", "15764 7.0 2.0 -79.924731 40.474284 \n", "15649 1.0 1.0 -79.992042 40.465360 \n", "15719 9.0 2.0 -79.908608 40.470381 \n", "15714 9.0 2.0 -79.908608 40.470381 \n", "7379 6.0 6.0 -80.000290 40.440526 \n", "2403 7.0 2.0 -79.943252 40.464531 \n", "15765 9.0 2.0 -79.891016 40.458322 \n", "10657 6.0 1.0 -80.027999 40.458723 \n", "15776 6.0 1.0 -80.024794 40.467289 \n", "\n", "[21104 rows x 17 columns]" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df.sort_values(by='ARRESTTIME') # sorting values by the date/time of arrest to see how far the data goes back" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "collapsed": true }, "outputs": [], "source": [ "# making columns for year and month based on the arresttime column\n", "df['Year']=df['ARRESTTIME'].apply(lambda x: int(x[:4]))\n", "df['Month']=df['ARRESTTIME'].apply(lambda x: int(x.split('-')[1]))" ] }, { "cell_type": "code", "execution_count": 6, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "2017 12022\n", "2018 4975\n", "2016 4087\n", "2014 6\n", "2015 5\n", "2011 2\n", "2007 2\n", "2013 1\n", "2012 1\n", "2008 1\n", "2006 1\n", "2005 1\n", "Name: Year, dtype: int64" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# try to get a sense for when the data starts being comprehensive. \n", "# Assume anything before then is not reliable.\n", "df['Year'].value_counts() " ] }, { "cell_type": "code", "execution_count": 7, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "2 2\n", "3 1\n", "4 11\n", "7 13\n", "8 638\n", "9 854\n", "10 883\n", "11 861\n", "12 824\n", "Name: Month, dtype: int64" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df[df['Year']==2016]['Month'].value_counts().sort_index() # when in 2016 does the data start being comprehensive" ] }, { "cell_type": "code", "execution_count": 8, "metadata": { "collapsed": false }, "outputs": [], "source": [ "# Filter AUGUST 2016 to the present\n", "df = df[(df['Year'].values>=2017) | ((df['Year'].values==2016) & (df['Month'].values>=8))]" ] }, { "cell_type": "code", "execution_count": 9, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "(21057, 1568)" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "dfMinor = df[df['AGE']<18] # a dataset for minors only\n", "len(df),len(dfMinor)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 1) What percent of all arrests are of minors, and how many are there in raw numbers " ] }, { "cell_type": "code", "execution_count": 10, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "18+ 19489\n", "<18 1568\n", "Name: isMinor, dtype: int64" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df['isMinor']=df['AGE'].apply(lambda x: '<18' if x<18 else '18+') # Add column saying whether the arrest is of a minor or not\n", "pieData = df['isMinor'].value_counts()\n", "pieData" ] }, { "cell_type": "code", "execution_count": 11, "metadata": { "collapsed": false }, "outputs": [ { "data": { "application/vnd.plotly.v1+json": { "data": [ { "hoverinfo": "label", "labels": [ "18+", "<18" ], "marker": { "colors": [ "rgb(169,169,169)", "Gold" ] }, "text": [ "92.6%
19489", "7.4%
1568" ], "textfont": { "color": "black", "size": 14 }, "textinfo": "text", "type": "pie", "values": [ 19489, 1568 ] } ], "layout": { "hovermode": "closest", "legend": { "font": { "size": 15 } }, "title": "Arrests in Pittsburgh by Age, August 2016-Present" } }, "text/html": [ "
" ], "text/vnd.plotly.v1+html": [ "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "labels = pieData.index\n", "values = pieData\n", "\n", "trace = go.Pie(labels=labels, values=values,marker=dict(colors=['rgb(169,169,169)','Gold']),hoverinfo='label',\n", " textinfo='text',\n", " text=['92.6%
19489','7.4%
1568'],\n", " textfont=dict(size=14,color='black'))\n", "data = go.Data([trace])\n", "\n", "layout = go.Layout(\n", " hovermode='closest',\n", " title = 'Arrests in Pittsburgh by Age, August 2016-Present',\n", " legend=dict(font=dict(size=15)))\n", "\n", "fig = go.Figure(data=data,layout=layout)\n", "\n", "plotly.offline.iplot(fig)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 2) Top youth offenses" ] }, { "cell_type": "code", "execution_count": 12, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "13(a)(31) Marijuana: Possession Small Amount 149\n", "2701 Simple Assault. 59\n", "2702 Aggravated Assault. 56\n", "2702 Aggravated Assault. / 5503(a)(4) DISORDERLY CONDUCT - HAZARDOUS/PHYS. OFF 51\n", "912 Possession of Weapon on School Property. 44\n", "2702 Aggravated Assault. / 5503 Disorderly Conduct. 33\n", "903 Criminal Conspiracy. / 3701 Robbery. 32\n", "3925 Receiving Stolen Property. 32\n", "2701 Simple Assault. / 5503 Disorderly Conduct. 29\n", "2701(a)(1) Simple Assault - Intent., Know., Reckless.Cause Bod. Injury 28\n", "Name: OFFENSES, dtype: int64" ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "dfMinor['OFFENSES'].value_counts().head(10) # Top ten offenses for youth - need to separate the multiple offenses out" ] }, { "cell_type": "code", "execution_count": 13, "metadata": { "collapsed": true }, "outputs": [], "source": [ "# split on ' / ' (with spaces) to separate different arrests, avoid hazardouse/phys. off from being separated. " ] }, { "cell_type": "code", "execution_count": 14, "metadata": { "collapsed": false }, "outputs": [], "source": [ "offenseCounts = dict() # initialize a dictionary\n", "for offenses in dfMinor['OFFENSES'].values: # for each entry in the offenses column...\n", " if not isinstance(offenses,str): continue # skip the nans\n", " offensesSplit = offenses.split(' / ') # split the multiple offenses up\n", " for offense in offensesSplit: # for each offense...\n", " if offense in offenseCounts: # if it is already in the dictionary, increase the count by one\n", " offenseCounts[offense]+=1\n", " else: # if it is not in the dictionary, add a new entry and start it at 1\n", " offenseCounts[offense]=1\n", "offenseCountsSer = pd.Series(offenseCounts) # turn dictionary into a series\n" ] }, { "cell_type": "code", "execution_count": 15, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "2702 Aggravated Assault. 331\n", "903 Criminal Conspiracy. 237\n", "13(a)(31) Marijuana: Possession Small Amount 213\n", "5503(a)(4) DISORDERLY CONDUCT - HAZARDOUS/PHYS. OFF 201\n", "2701 Simple Assault. 185\n", "3925 Receiving Stolen Property. 149\n", "5503 Disorderly Conduct. 134\n", "3701 Robbery. 119\n", "2701(a)(1) Simple Assault - Intent., Know., Reckless.Cause Bod. Injury 118\n", "6110.1 Possesion of Firearm by Minor 113\n", "2705 Recklessy Endangering Another Person. 102\n", "5503(a)(1) DISORDERLY CONDUCT - ENGAGE IN FIGHTING 94\n", "13(a)(16) Possession of Controlled Substance 90\n", "6106 Firearms not to be Carried without a License. 72\n", "912 Possession of Weapon on School Property. 66\n", "13(a)(30) Possession w/ Intent to Del. Controlled Substance 60\n", "2706 Terroristic Threats. 58\n", "5104 Resisting Arrest or Other Law Enforcement. 58\n", "3921 Theft by Unlawful Taking or Disposition. 53\n", "3304 Criminal Mischief. 51\n", "dtype: int64" ] }, "execution_count": 15, "metadata": {}, "output_type": "execute_result" } ], "source": [ "offenseCountsSer.sort_values(ascending=False).head(20) # now see the top offenses, separated out" ] }, { "cell_type": "code", "execution_count": 16, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "6110.1 Possesion of Firearm by Minor 113\n", "2701(a)(1) Simple Assault - Intent., Know., Reckless.Cause Bod. Injury 118\n", "3701 Robbery. 119\n", "5503 Disorderly Conduct. 134\n", "3925 Receiving Stolen Property. 149\n", "2701 Simple Assault. 185\n", "5503(a)(4) DISORDERLY CONDUCT - HAZARDOUS/PHYS. OFF 201\n", "13(a)(31) Marijuana: Possession Small Amount 213\n", "903 Criminal Conspiracy. 237\n", "2702 Aggravated Assault. 331\n", "dtype: int64" ] }, "execution_count": 16, "metadata": {}, "output_type": "execute_result" } ], "source": [ "topYouthOffenses = offenseCountsSer.sort_values(ascending=True).tail(10) # top 10\n", "topYouthOffenses " ] }, { "cell_type": "code", "execution_count": 17, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "Index(['Possesion of Firearm by Minor', 'Simple Assault - Type A1', 'Robbery',\n", " 'Disorderly Conduct', 'Receiving Stolen Property', 'Simple Assault',\n", " 'Disorderly Conduct - Hazardous/Phys. Off',\n", " 'Marijuana: Possession Small Amount', 'Criminal Conspiracy',\n", " 'Aggravated Assault'],\n", " dtype='object')" ] }, "execution_count": 17, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# get rid of the number/letter codes\n", "topYouthOffenses.index = map(lambda s: s.split(' ',1)[1:][0],topYouthOffenses.index) \n", "\n", "# shorten some of the longer names\n", "dictt = {'DISORDERLY CONDUCT - HAZARDOUS/PHYS. OFF':'Disorderly Conduct - Hazardous/Phys. Off',\n", " 'Simple Assault - Intent., Know., Reckless.Cause Bod. Injury':'Simple Assault - Type A1'}\n", "topYouthOffenses.index = map(lambda s: dictt[s] if s in dictt else s.replace('.',''),topYouthOffenses.index)\n", "topYouthOffenses.index" ] }, { "cell_type": "code", "execution_count": 18, "metadata": { "collapsed": false }, "outputs": [ { "data": { "application/vnd.plotly.v1+json": { "data": [ { "marker": { "color": "rgb(255,102,102)" }, "name": [ "Possesion of Firearm by Minor", "Simple Assault - Type A1", "Robbery", "Disorderly Conduct", "Receiving Stolen Property", "Simple Assault", "Disorderly Conduct - Hazardous/Phys. Off", "Marijuana: Possession Small Amount", "Criminal Conspiracy", "Aggravated Assault" ], "orientation": "h", "text": [ 113, 118, 119, 134, 149, 185, 201, 213, 237, 331 ], "textfont": { "color": "white", "size": 14 }, "textposition": "auto", "type": "bar", "x": [ 113, 118, 119, 134, 149, 185, 201, 213, 237, 331 ], "y": [ "Possesion of Firearm by Minor", "Simple Assault - Type A1", "Robbery", "Disorderly Conduct", "Receiving Stolen Property", "Simple Assault", "Disorderly Conduct - Hazardous/Phys. Off", "Marijuana: Possession Small Amount", "Criminal Conspiracy", "Aggravated Assault" ] } ], "layout": { "hovermode": "closest", "margin": { "b": 50, "l": 300, "pad": 4, "r": 10, "t": 50 }, "title": "Top Alleged Offenses by Minors Arrested in Pittsburgh, August 2016-Present", "xaxis": { "title": "Arrests" } } }, "text/html": [ "
" ], "text/vnd.plotly.v1+html": [ "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "# Make a bar graph showing the top offenses\n", "trace = go.Bar(x=topYouthOffenses,\n", " y=topYouthOffenses.index,\n", " name=topYouthOffenses.index,\n", " orientation='h',\n", " marker=dict(color='rgb(255,102,102)'),\n", " text=topYouthOffenses,\n", " textposition = 'auto',\n", " textfont=dict(\n", " size=14,\n", " color='white'))\n", "data = go.Data([trace])\n", "\n", "layout = go.Layout(\n", " hovermode='closest',\n", " xaxis = {'title': 'Arrests'},\n", " title = 'Top Alleged Offenses by Minors Arrested in Pittsburgh, August 2016-Present',\n", " margin = {'l':300, 'r':10, 'b':50, 't':50, 'pad':4})\n", "\n", "# CAPTION: A Type A1 Simple Assault refers to intentionally, knowingly, or recklessly causing bodily injury.\n", "fig = go.Figure(data=data,layout=layout)\n", "\n", "# MAKE A NOTE THAT SOME MIGHT BE ARRESTED FOR MULTIPLE OFFENSES \n", "plotly.offline.iplot(fig)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 3) Race and gender breakdown" ] }, { "cell_type": "code", "execution_count": 19, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "1568\n" ] }, { "data": { "text/plain": [ "B 1311\n", "W 178\n", "O 43\n", "H 15\n", "U 14\n", "A 7\n", "Name: RACE, dtype: int64" ] }, "execution_count": 19, "metadata": {}, "output_type": "execute_result" } ], "source": [ "print(len(dfMinor['RACE']))\n", "dfMinor['RACE'].value_counts()" ] }, { "cell_type": "code", "execution_count": 20, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "RACE GENDER\n", "A F 2\n", " M 5\n", "B F 385\n", " M 921\n", " U 5\n", "H F 3\n", " M 12\n", "O F 14\n", " M 29\n", "U F 2\n", " M 11\n", " U 1\n", "W F 44\n", " M 134\n", "dtype: int64" ] }, "execution_count": 20, "metadata": {}, "output_type": "execute_result" } ], "source": [ "dfMinor.groupby([\"RACE\", \"GENDER\"]).size()" ] }, { "cell_type": "code", "execution_count": 21, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "B 921\n", "W 134\n", "H 12\n", "A 5\n", "U 11\n", "O 29\n", "Name: RACE, dtype: int64" ] }, "execution_count": 21, "metadata": {}, "output_type": "execute_result" } ], "source": [ "maleArrests = dfMinor[dfMinor.GENDER=='M']['RACE']\n", "# rearranging the order \n", "bw = maleArrests.value_counts()[0:2]\n", "h = maleArrests.value_counts()[3:4]\n", "a = maleArrests.value_counts()[-1:]\n", "u = maleArrests.value_counts()[-2:-1]\n", "o = maleArrests.value_counts()[2:3]\n", "maleArrests = bw.append(h).append(a).append(u).append(o)\n", "maleArrests" ] }, { "cell_type": "code", "execution_count": 22, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "B 385\n", "W 44\n", "H 3\n", "U 2\n", "A 2\n", "O 14\n", "Name: RACE, dtype: int64" ] }, "execution_count": 22, "metadata": {}, "output_type": "execute_result" } ], "source": [ "femaleArrests = dfMinor[dfMinor.GENDER=='F']['RACE']\n", "# rearranging the order\n", "bw = femaleArrests.value_counts()[0:2]\n", "h = femaleArrests.value_counts()[3:4]\n", "a = femaleArrests.value_counts()[-1:]\n", "u = femaleArrests.value_counts()[-2:-1]\n", "o = femaleArrests.value_counts()[2:3]\n", "femaleArrests = bw.append(h).append(a).append(u).append(o)\n", "femaleArrests" ] }, { "cell_type": "code", "execution_count": 23, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "B 5\n", "U 1\n", "Name: RACE, dtype: int64" ] }, "execution_count": 23, "metadata": {}, "output_type": "execute_result" } ], "source": [ "GenderUnknownArrests = dfMinor[dfMinor.GENDER=='U']['RACE'].value_counts()\n", "GenderUnknownArrests" ] }, { "cell_type": "code", "execution_count": 24, "metadata": { "collapsed": true }, "outputs": [], "source": [ "races = ['Black','White','Hispanic','Asian','Unknown','Other']" ] }, { "cell_type": "code", "execution_count": 25, "metadata": { "collapsed": false }, "outputs": [ { "data": { "application/vnd.plotly.v1+json": { "data": [ { "marker": { "color": "rgb(102,178,255)" }, "name": "Male", "text": [ 921, 134, 12, 5, 11, 29 ], "textfont": { "color": "black", "size": 12 }, "textposition": "auto", "type": "bar", "x": [ "Black", "White", "Hispanic", "Asian", "Unknown", "Other" ], "y": [ 921, 134, 12, 5, 11, 29 ] }, { "marker": { "color": "rgb(255,178,102)" }, "name": "Female", "text": [ 385, 44, 3, 2, 2, 14 ], "textfont": { "color": "black", "size": 12 }, "textposition": "auto", "type": "bar", "x": [ "Black", "White", "Hispanic", "Asian", "Unknown", "Other" ], "y": [ 385, 44, 3, 2, 2, 14 ] } ], "layout": { "hovermode": "closest", "legend": { "font": { "size": 14 } }, "title": "Race and Gender of Minors Arrested in Pittsburgh, August 2016-Present", "xaxis": { "title": "Race/Gender" }, "yaxis": { "title": "Arrests" } } }, "text/html": [ "
" ], "text/vnd.plotly.v1+html": [ "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "trace1 = go.Bar(x=races,\n", " y=maleArrests,\n", " name=\"Male\",\n", " marker=dict(color='rgb(102,178,255)'),\n", " text=maleArrests,\n", " textposition = 'auto',\n", " textfont=dict(\n", " size=12,\n", " color='black'))\n", "\n", "trace2 = go.Bar(x=races,\n", " y=femaleArrests,\n", " name=\"Female\",\n", " marker=dict(color='rgb(255,178,102)'),\n", " text=femaleArrests,\n", " textposition = 'auto',\n", " textfont=dict(\n", " size=12,\n", " color='black'))\n", " \n", "# GOING TO EXCLUDE 6 CASES WHERE GENDER IS UNKNOWN (MAYBE MAKE A NOTE OF THIS IN ARTICLE OR IN FOOTNOTE TO GRAPH)\n", "# trace3 = go.Bar(x=GenderUnknownArrests.index,\n", "# y=GenderUnknownArrests,\n", "# name=\"Gender Unknown\")\n", "\n", "data = go.Data([trace1,trace2])\n", "\n", "layout = go.Layout(\n", " hovermode='closest',\n", " xaxis = {'title':'Race/Gender'},\n", " yaxis = {'title': 'Arrests'},\n", " title = 'Race and Gender of Minors Arrested in Pittsburgh, August 2016-Present',\n", " legend = dict(font=dict(size=14))\n", " )\n", "\n", "fig = go.Figure(data=data,layout=layout)\n", "\n", "plotly.offline.iplot(fig)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 4\n", "### Convert to CSV to send to ArcGIS to make map" ] }, { "cell_type": "code", "execution_count": 26, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
_idPKCCRAGEGENDERRACEARRESTTIMEARRESTLOCATIONOFFENSESINCIDENTLOCATION...COUNCIL_DISTRICTPUBLIC_WORKS_DIVISIONXYYearMonthRace_FullGender_FullDateTime
38354719790791615013917MB2016-12-20T13:40:00900 Block 2ND AV Pittsburgh, PA 15219903 Criminal Conspiracy. / 3701 Robbery.100 Block N St Clair ST Pittsburgh, PA 15206...9.02.0-79.92746540.464938201612BlackMale2016-12-2013:40:00
44840219851641707677812MB2017-05-02T11:45:00600 Block 1ST AV PITTSBURGH, PA 152192705 Recklessy Endangering Another Person. / 2...600 Block FILBERT ST PITTSBURGH, PA 15232...8.02.0-79.93418640.45321920175BlackMale2017-05-0211:45:00
551179419893281715129314FB2017-08-10T21:00:00700 Block Chautauqua ST Pittsburgh, PA 152142701 Simple Assault.700 Block Chautauqua CT Pittsburgh, PA 15214...6.01.0-80.01785140.46388720178BlackFemale2017-08-1021:00:00
761554419941111720782417FB2017-12-05T09:00:00600 Block 1ST AV PITTSBURGH, PA 152192701 Simple Assault. / 5503(a)(4) DISORDERLY C...1100 Block N MURTLAND ST PITTSBURGH, PA 15208...9.02.0-79.90014240.460411201712BlackFemale2017-12-0509:00:00
117680919830811703370312FB2017-03-13T14:15:00600 Block 1ST AV PITTSBURGH, PA 1521913(a)(31) Marijuana: Possession Small Amount3500 Block FLEMING AV PITTSBURGH, PA 15212...1.01.0-80.03847540.47858820173BlackFemale2017-03-1314:15:00
\n", "

5 rows × 23 columns

\n", "
" ], "text/plain": [ " _id PK CCR AGE GENDER RACE ARRESTTIME \\\n", "38 3547 1979079 16150139 17 M B 2016-12-20T13:40:00 \n", "44 8402 1985164 17076778 12 M B 2017-05-02T11:45:00 \n", "55 11794 1989328 17151293 14 F B 2017-08-10T21:00:00 \n", "76 15544 1994111 17207824 17 F B 2017-12-05T09:00:00 \n", "117 6809 1983081 17033703 12 F B 2017-03-13T14:15:00 \n", "\n", " ARRESTLOCATION \\\n", "38 900 Block 2ND AV Pittsburgh, PA 15219 \n", "44 600 Block 1ST AV PITTSBURGH, PA 15219 \n", "55 700 Block Chautauqua ST Pittsburgh, PA 15214 \n", "76 600 Block 1ST AV PITTSBURGH, PA 15219 \n", "117 600 Block 1ST AV PITTSBURGH, PA 15219 \n", "\n", " OFFENSES \\\n", "38 903 Criminal Conspiracy. / 3701 Robbery. \n", "44 2705 Recklessy Endangering Another Person. / 2... \n", "55 2701 Simple Assault. \n", "76 2701 Simple Assault. / 5503(a)(4) DISORDERLY C... \n", "117 13(a)(31) Marijuana: Possession Small Amount \n", "\n", " INCIDENTLOCATION ... COUNCIL_DISTRICT \\\n", "38 100 Block N St Clair ST Pittsburgh, PA 15206 ... 9.0 \n", "44 600 Block FILBERT ST PITTSBURGH, PA 15232 ... 8.0 \n", "55 700 Block Chautauqua CT Pittsburgh, PA 15214 ... 6.0 \n", "76 1100 Block N MURTLAND ST PITTSBURGH, PA 15208 ... 9.0 \n", "117 3500 Block FLEMING AV PITTSBURGH, PA 15212 ... 1.0 \n", "\n", " PUBLIC_WORKS_DIVISION X Y Year Month Race_Full \\\n", "38 2.0 -79.927465 40.464938 2016 12 Black \n", "44 2.0 -79.934186 40.453219 2017 5 Black \n", "55 1.0 -80.017851 40.463887 2017 8 Black \n", "76 2.0 -79.900142 40.460411 2017 12 Black \n", "117 1.0 -80.038475 40.478588 2017 3 Black \n", "\n", " Gender_Full Date Time \n", "38 Male 2016-12-20 13:40:00 \n", "44 Male 2017-05-02 11:45:00 \n", "55 Female 2017-08-10 21:00:00 \n", "76 Female 2017-12-05 09:00:00 \n", "117 Female 2017-03-13 14:15:00 \n", "\n", "[5 rows x 23 columns]" ] }, "execution_count": 26, "metadata": {}, "output_type": "execute_result" } ], "source": [ "raceDict = {'A':'Asian','B':'Black','O':'Other','U':'Unknown','W':'White','H':'Hispanic'}\n", "genderDict = {'M':'Male','F':'Female','U':'Unknown'}\n", "dfMinor['Race_Full']=dfMinor['RACE'].apply(lambda s: raceDict[s])\n", "dfMinor['Gender_Full']=dfMinor['GENDER'].apply(lambda s: genderDict[s])\n", "dfMinor['Date']=dfMinor['ARRESTTIME'].apply(lambda s: s.split('T')[0])\n", "dfMinor['Time']=dfMinor['ARRESTTIME'].apply(lambda s: s.split('T')[1])\n", "dfMinor['AGE']=dfMinor['AGE'].apply(int)\n", "dfMinor.head()" ] }, { "cell_type": "code", "execution_count": 27, "metadata": { "collapsed": false }, "outputs": [], "source": [ "#dfMinor.to_csv(\"MinorData.csv\",index=False)" ] } ], "metadata": { "anaconda-cloud": {}, "kernelspec": { "display_name": "Python [default]", "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.5.2" } }, "nbformat": 4, "nbformat_minor": 2 }