Visualize data with python
— Take New York City crime data as an example

Yuanchen Zhao
2 min readDec 2, 2019

--

Crime rates in a city have been a constant concern for governments and residents.

Through the public data of NYPD, Complaint Data of New York City, I analyzed the crime rate of the five boroughs and collected all the data from 2006 to 2017 to get the following picture.

From the picture, we can see that from 2006 to 2017, Staten Island had the lowest crime rate in five boroughs, only 4.15 %. Brooklyn has the highest crime rate of 28.83%. Although Manhattan doesn’t have the largest crime rate in five boroughs, because of its smallest area, we cannot rule out that Manhattan is not the region with the highest crime rate density.

In addition to the regional distribution, I also calculated the time distribution of crime. As shown in the figure below, we can clearly see that the early morning is the time when the crime rate is the lowest, at about 4 am to 7 am. From 1 am to 3 am, the graph has a small peak, and then the number of crimes gradually decreases to form a trough between about 4 am and 6 am. The number of crimes increased significantly after 7 am, until the highest peak was around 3 pm, and continued until 9 pm. After 9 pm, the number of crimes has gradually decreased.

Time variation of crime rate in New York City
Time variation of crime rate in New York City

note: 0.0 means Sunday, The following 1.0–6.0 represent Monday to Saturday.

According to the icon analysis, it is recommended that the police station strengthen the police force from 3 pm to 9 pm and 12 pm to 3 am.

Source from:

NYPD Complaint Data Historic https://data.cityofnewyork.us/Public-Safety/NYPD-Complaint-Data-Historic/qgea-i56i

Analysis process in python: https://colab.research.google.com/drive/1Z0wRWAYBguHMppOrQNe0SIURfiVPUOD0#scrollTo=pVFtr2pbTRr-

--

--

Yuanchen Zhao
0 Followers

Someone interested in urban planning and visual data