DEV Community

Cover image for Data Analysis With Python: Analysis of gun violence incidents in the USA.
Oluwafunmilola Obisesan
Oluwafunmilola Obisesan

Posted on • Updated on

Data Analysis With Python: Analysis of gun violence incidents in the USA.

After the school shooting that happened some weeks ago in Uvalde, Texas, I was prompted to carry some data analysis on gun violence incidents in the USA.
Read my findings here.

     **************
Enter fullscreen mode Exit fullscreen mode

The dataset for this project contains records of gun violence incidents across the 50 states of the United States of America within the period of December 28, 2018 to June 20, 2022.
Data cleaning, analysis and visualization was done using python. The analysis provides answers to some important questions and to get an understanding of the dataset.

Data Structure:
Columns in the dataset include; Incident ID, Incident Date, State, City and the Address where the gun violence incident happened.

  • The necessary python libraries needed to carry out this analysis was imported into the python IDLE (Jupyter Notebook), And the dataset was loaded in to begin analysis.

Image description

  • Total numbers of column and rows present in the dataset shows 2000 rows and 7 columns.

Image description

  • 10 random samples of the dataset to see what the dataset looks like.

Image description

Data Cleaning
Data cleaning was done using the python pandas library in order to “clean “ the dataset and prepare it for analysis.

  • Checking for missing values in the dataset

Image description
The image above shows the dataset had missing values in the “Address” column, this missing values were then replaced with “not available “, since we can not replace the missing addresses with any random address.

Image description

  • Checking for duplicates in the dataset to avoid inaccuracy in the results.

Image description
The image above shows there were no duplicates in the dataset.
Superb!!!

Data Analysis and Exploration
Analysis was done to answer some key questions and to get useful information.
1) Total number of gun violence incidents in the USA within the period of this record; December 28, 2018 to June 20, 2022.

Image description

The analysis shows there were 2000 gun violence incidents in the USA within the period stated above.

2) Total number of people killed within the period:

Image description

Analysis shows, 2003 people were killed within the period of this record.

3) Total number of people injured.

Image description

8299 people were injured due to gun violence incident within the period of this record.

4) Top ten states with the most gun violence incidents

Image description

Image description
I was particularly surprised by this result, I really didn’t expect Illinois to top this chart. This further shows, Data analysis gives result based on facts and not intuition.

5) Bottom ten state with the LEAST gun violence incident.

Image description

Image description

Wyoming, Maine and New Hampshire had just 1 gun violence incidents within the period.

6) Top ten states with the most deaths:

Image description
Image description
Texas had the most deaths within this period, with a total of 231 people killed due to gun violence incidents.
Crazy!

7) Top ten city with the most gun violence incident:

Image description

Image description
Chicago, A city in Illinois had the most gun violence incidents across all cities in the USA.

8) Bottom five city with the least incidents:

Image description

Image description

Lima, salt lake, cleavland, Inkster and West Jefferson were the cities with least incidents.

9) Top five addresses with the most gun violence incidents:

Image description

Image description

NB: four rows in the address column were missing and were replaced with “not available” as explained earlier, hence the not available in the image above. The other four addresses had the most gun violence incidents within the period of this record.

         *************
Enter fullscreen mode Exit fullscreen mode

To view the entire code for this project, please check out my GitHub profile for the Jupyter notebook: https://github.com/heyfunmi/Gun-violence-Analysis

Thank you for reading!

For comments and suggestions, please reach me via: heyfunmi@gmail.com

Top comments (0)