Analysis by Jennifer Karnosky
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
%matplotlib inline
massShoot = pd.read_csv('MassShootingsData.csv')
fig,ax = plt.subplots()
massShoot.index = pd.DatetimeIndex(freq='m',data=pd.date_range(freq='m',start=pd.Timestamp(year=1992,month=5,day=1),periods=len(massShoot.date)))
ax.plot(massShoot['fatalities'], label = 'Fatally Wounded')
ax.set_xlabel('Year')
ax.set_ylabel('Fatally Wounded Victims')
ax.spines['right'].set_visible(False)
ax.spines['top'].set_visible(False)
fig.set_size_inches(15,10)
fig.suptitle('Mass Shooting Fatalities in the US from May 1992 - May 2022 ',fontsize= 16)
ax.axvspan(8505,12500,ymin=0,ymax = 80,facecolor='k',alpha=0.1)
ax.text(10500,30,'10 Year\n Assault Weapons Ban',fontsize=14,verticalalignment='center',horizontalalignment='center',fontname='Times New Roman')
ax.axvspan(17300,17550,ymin=0,ymax = 80,facecolor='r',alpha=0.1)
plt.text(17300, 50, 'Las Vegas Massacre', ha='center', va='center',rotation='vertical')
Text(17300, 50, 'Las Vegas Massacre')
AR= pd.read_csv('MJ_MSDatabase.csv')
#ARys= youngShooter.loc[youngShooter['weapon_type'] == 'AR_1Plus']
ARyes= AR.loc[AR['weapon_type'] == 'AR_1Plus']
print(ARyes)
yesTotal= ARyes['total_victims'].sum()
print(yesTotal) #35 shootings
fatalities injured total_victims age_of_shooter weapon_type 92 21 17 38 18.0 AR_1Plus 93 10 3 13 18.0 AR_1Plus 94 8 7 15 19.0 AR_1Plus 95 10 0 10 21.0 AR_1Plus 96 7 25 32 36.0 AR_1Plus 97 9 27 36 24.0 AR_1Plus 98 22 26 48 21.0 AR_1Plus 99 3 12 15 19.0 AR_1Plus 100 11 6 17 46.0 AR_1Plus 101 4 4 8 29.0 AR_1Plus 102 3 0 3 36.0 AR_1Plus 103 17 17 34 19.0 AR_1Plus 104 4 1 5 28.0 AR_1Plus 105 5 10 15 44.0 AR_1Plus 106 26 20 46 26.0 AR_1Plus 107 58 546 604 64.0 AR_1Plus 108 3 3 6 29.0 AR_1Plus 109 5 11 16 25.0 AR_1Plus 110 49 53 102 29.0 AR_1Plus 111 3 14 17 38.0 AR_1Plus 112 6 2 8 45.0 AR_1Plus 113 14 21 35 28.0 AR_1Plus 114 6 3 9 23.0 AR_1Plus 115 27 2 29 20.0 AR_1Plus 116 12 70 82 24.0 AR_1Plus 117 5 7 12 32.0 AR_1Plus 118 9 4 13 19.0 AR_1Plus 119 6 1 7 20.0 AR_1Plus 120 7 2 9 28.0 AR_1Plus 121 7 0 7 42.0 AR_1Plus 122 13 24 37 17.0 AR_1Plus 123 5 2 7 41.0 AR_1Plus 124 5 23 28 20.0 AR_1Plus 125 9 12 21 47.0 AR_1Plus 126 6 29 35 26.0 AR_1Plus 127 22 19 41 41.0 AR_1Plus 1460
ARno= AR.loc[AR['weapon_type'] == 'NonAR']
print(ARno)
noTotal= ARno['total_victims'].sum()
print(noTotal) #92 Shootings
fatalities injured total_victims age_of_shooter weapon_type 0 4 0 4 NaN NonAR 1 8 1 9 21.0 NonAR 2 4 0 4 31.0 NonAR 3 4 3 7 NaN NonAR 4 5 2 7 24.0 NonAR .. ... ... ... ... ... 87 8 1 9 42.0 NonAR 88 4 25 29 15.0 NonAR 89 7 4 11 39.0 NonAR 90 10 5 15 16.0 NonAR 91 5 10 15 11.0 NonAR [92 rows x 5 columns] 1054
total = [noTotal, yesTotal]
weapon = ['Other Firearm', 'Assualt Rifle']
fig,ax = plt.subplots()
ax.bar(weapon,total, width= 0.3, edgecolor='white', linewidth=3)
ax.xaxis.set_label_text('Weapon Type',fontsize= 14)
ax.yaxis.set_label_text('Total Victims', fontsize= 14)
ax.spines['top'].set_visible(False)
ax.spines['right'].set_visible(False)
fig.set_size_inches(5,7)
fig.suptitle('Victim Totals and Assault Rifle Usage For Mass Shootings in the US from May 1992 - May 2022', fontsize=16)
ax.text(1,520, 'Resulting from 35 Mass Shootings', ha='center', va='center',rotation='vertical', color='w',fontsize= 15 )
ax.text(0,520, 'Resulting from 92 Mass Shootings', ha='center', va='center',rotation='vertical', color='w',fontsize= 14 )
fig.tight_layout()
plt.show()