Skip to content

1 hidden cell

Analyzing Crime Patterns in Los Angeles

Executive Summary

This project involved analyzing crime data from the Los Angeles Police Department (LAPD) to identify patterns in criminal behavior. Using historical crime records, we explored peak hours for criminal activity, locations with the highest incidents at night, and the distribution of victims by age group. The insights gained can support LAPD resource allocation and crime prevention strategies.

Business Problem

Los Angeles is a densely populated city with a high volume of criminal activity. Efficient deployment of police resources requires understanding when and where crimes occur, as well as which demographics are most affected. The challenge was to extract actionable insights from a large, real-world dataset to inform decision-making.

Methodology

Data preparation:
Loaded crime data and parsed date/time fields.
Converted TIME OCC to integer hours for analysis.

Peak crime analysis:
Determined the hour of the day with the highest crime frequency.
Focused on night-time hours (22:00โ€“03:00) to identify hotspots.

Demographic analysis:
Categorized victims into age groups using pd.cut().
Calculated the distribution of crimes across age ranges.

Visualization:
Used seaborn and matplotlib to create plots of hourly crime counts and victim age distributions.

Skills

Python
Libraries: pandas, numpy, matplotlib, seaborn.
Commands/Functions: pd.read_csv(), pd.cut(), .value_counts(), .astype(int).
sns.countplot() and plt.show() for visualizations.
Data handling: datetime parsing, categorical binning, filtering subsets.

Results

Peak crime hour: 23:00 โ€” the highest number of incidents occurred late at night.
Night-time crime hotspot: Downtown was the area with the most incidents between 22:00โ€“03:00.
Victim age distribution: The most affected age group was 18โ€“25, followed by 26โ€“34.\

Recommendations

Increase patrols and surveillance in Downtown during late-night hours.
Target preventive programs and community outreach to younger populations.
Monitor patterns over time to detect emerging hotspots or changes in crime trends.\

Next Steps

Integrate geographic data to produce heatmaps of crime locations.
Analyze crime type distribution to differentiate violent vs. non-violent incidents.
Use predictive modeling to anticipate crime spikes based on historical trends.
Incorporate seasonal, day-of-week, or special-event factors to refine policing strategies.

๐Ÿ”๐Ÿ“ˆ๐Ÿ“Š Analysis & Visualizations

# Re-run this cell
#ย Import required libraries
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
crimes = pd.read_csv("crimes.csv", parse_dates=["Date Rptd", "DATE OCC"], dtype={"TIME OCC": str})
crimes.head()
# Start coding here
# Use as many cells as you need
#crimes.info()

#peak_crime_hour as int
crimes['hour_occ'] = crimes['TIME OCC'].str[:2].astype(int)
print(crimes['hour_occ'])
sns.countplot(data=crimes, x='hour_occ')
plt.show()

peak_crime_hour = crimes['hour_occ'].value_counts().idxmax()
print(peak_crime_hour)

#peak_night_crime_location as str

night_crimes = crimes[crimes['hour_occ'].isin([22,23,0,1,2,3,])]
print(night_crimes.info())

peak_night_crime_location = night_crimes['AREA NAME'].value_counts(normalize=True).idxmax()
print(peak_night_crime_location)

#number crimes by victim age
labels = ['0-17', '18-25', '26-34', '35-44', '45-54', '55-64', '65+']
crimes['age_group'] = pd.cut(crimes['Vict Age'], bins=[0, 17, 25, 34, 44, 54, 64, 100], labels=labels)
victim_ages = crimes['age_group'].value_counts()

print(victim_ages)