For Writing KING

ChenJunLong
StateCrimeAnalysis.html

Analysis of State Crime Data

By Austin Cory Bart For CS-1064 Introduction to Programming in Python Spring 2018 I have neither given nor received unauthorized assistance on this assignment.

This notebook analyses state crime data from the United States Uniform Crime Reports. This data was made available through the CORGIS collection. The data describes the incidence rates of crimes throughout the United States over a 50-year period at the state level. The data is important for understanding the trend in crimes around the country. Rising crime rates is frequently used as a justification for implementing stricter policies involving tough issues like gun control, increased incarceration, and police militarization. It is also a cause for concern for homebuyers who are considering moving to an area.

Loading the Data

In [17]:
# Load
import requests
reports = requests.get("https://think.cs.vt.edu/corgis/json/state_crime/state_crime.json").json()

# Preview the data
from pprint import pprint
pprint(reports[0])
{'Data': {'Population': 3266740,
          'Rates': {'Property': {'All': 1035.4,
                                 'Burglary': 355.9,
                                 'Larceny': 592.1,
                                 'Motor': 87.3},
                    'Violent': {'All': 186.6,
                                'Assault': 138.1,
                                'Murder': 12.4,
                                'Rape': 8.6,
                                'Robbery': 27.5}},
          'Totals': {'Property': {'All': 33823,
                                  'Burglary': 11626,
                                  'Larceny': 19344,
                                  'Motor': 2853},
                     'Violent': {'All': 6097,
                                 'Assault': 4512,
                                 'Murder': 406,
                                 'Rape': 281,
                                 'Robbery': 898}}},
 'State': 'Alabama',
 'Year': 1960}

Histogram Analysis

In [18]:
# Preprocess
murder_rates_in_2010 = []
for report in reports:
    # Filter out other years besides 2010
    if report['Year'] == 2010:
        # Filter out the United States Total
        if report['State'] != "United States":
            murders = report['Data']['Rates']['Violent']['Murder']
            murder_rates_in_2010.append(murders)

import matplotlib.pyplot as plt

plt.hist(murder_rates_in_2010)
plt.title("Murder Rates across States in 2010")
plt.xlabel("Murder Rates")
plt.ylabel("Number of Murders")
plt.show()

This histogram shows that the murder across states is actually relatively similar. Most states have a murder rate between 1 and 10, with only a few outliers from that value.

Trend Analysis

For my secondary analysis, I will create a line plot that shows the change in murder rate over time, for the state of Delaware.

In [19]:
# Extract out Delaware's data
delaware_murders = []
delaware_years = []
for report in reports:
    if report['State'] == 'Delaware':
        murders = report['Data']['Rates']['Violent']['Murder']
        delaware_murders.append(murders)
        delaware_years.append(report['Year'])

plt.plot(delaware_years, delaware_murders)
plt.xlabel("Time (years)")
plt.ylabel("Murder Rate (per 10k people)")
plt.title("Murder Rate over Time in Delaware")
plt.show()

This graph shows that the murder rate in Delaware has fluctuated over time, but was generally going down until the past decade.

Stakeholder Analysis

Two stakeholders who might be interested in this analysis are:

  • Delaware Policy Makers, who would be interested to know that crime may be on the rise in their state so that they can implement measures to stop the rise in crime.
  • People Buying Houses in Delaware, who might want to explore whether the crime rate in their potential county is similar to the state average, and potentially live somewhere else.