In [47]:
import numpy as np
import pandas as pd
import seaborn as sns
In [75]:
import matplotlib.pyplot as plt
import matplotlib
color = sns.color_palette()
In [11]:
data_path = 'dataset/us-mass-shootings-last-50-years/Mass Shootings Dataset.csv'
data_path2 = 'dataset/us-mass-shootings-last-50-years/Mass Shootings Dataset Ver 2.csv'
In [51]:
data1 = pd.read_csv(data_path,encoding = "ISO-8859-1", parse_dates=["Date"])
data2 = pd.read_csv(data_path2,encoding = "ISO-8859-1", parse_dates=["Date"])
In [52]:
data1.head()
Out[52]:
In [53]:
data2.head()
Out[53]:
In [55]:
float(data2['Total victims'].sum())/len(data2['Total victims'])
Out[55]:
In [59]:
years = [y.year for y in data2['Date']]
ylen = len(set(years))
float(data2['Total victims'].sum())/ylen
Out[59]:
In [60]:
float(data2['Injured'].sum())/ylen
Out[60]:
In [61]:
float(data2['Injured'].sum())
Out[61]:
In [44]:
float(data2['Fatalities'].sum())/ylen
Out[44]:
In [ ]:
In [64]:
plt.figure(figsize=(10,8))
plt.scatter(np.sort(data2['Date']),np.sort(data2['Total victims'].valaues))
plt.xlabel('Years')
plt.ylabel('No of victims')
plt.show()
In [ ]:
In [89]:
cnt_ms = data2['Date'].dt.year.value_counts()
plt.figure(figsize=(12,10))
sns.barplot(cnt_ms.index,cnt_ms.values,alpha=0.8,color=color[0])
plt.xticks(rotation = 'vertical')
plt.title('Attcaks over years')
plt.show()
In [ ]: