Mass shootings in America in 2015

Data from http://www.shootingtracker.com/Main_Page

Important! Their definition of mass shooting is: FOUR or more shot and/or killed in a single event [incident], at the same general time and location, not including the shooter.


In [1]:
!pip install pandas


Requirement already satisfied (use --upgrade to upgrade): pandas in /Users/mercybenzaquen/.virtualenvs/Homework8/lib/python3.5/site-packages
Requirement already satisfied (use --upgrade to upgrade): python-dateutil>=2 in /Users/mercybenzaquen/.virtualenvs/Homework8/lib/python3.5/site-packages (from pandas)
Requirement already satisfied (use --upgrade to upgrade): pytz>=2011k in /Users/mercybenzaquen/.virtualenvs/Homework8/lib/python3.5/site-packages (from pandas)
Requirement already satisfied (use --upgrade to upgrade): numpy>=1.7.0 in /Users/mercybenzaquen/.virtualenvs/Homework8/lib/python3.5/site-packages (from pandas)
Requirement already satisfied (use --upgrade to upgrade): six>=1.5 in /Users/mercybenzaquen/.virtualenvs/Homework8/lib/python3.5/site-packages (from python-dateutil>=2->pandas)

In [2]:
!pip install matplotlib


Requirement already satisfied (use --upgrade to upgrade): matplotlib in /Users/mercybenzaquen/.virtualenvs/Homework8/lib/python3.5/site-packages
Requirement already satisfied (use --upgrade to upgrade): cycler in /Users/mercybenzaquen/.virtualenvs/Homework8/lib/python3.5/site-packages (from matplotlib)
Requirement already satisfied (use --upgrade to upgrade): pyparsing!=2.0.0,!=2.0.4,>=1.5.6 in /Users/mercybenzaquen/.virtualenvs/Homework8/lib/python3.5/site-packages (from matplotlib)
Requirement already satisfied (use --upgrade to upgrade): python-dateutil in /Users/mercybenzaquen/.virtualenvs/Homework8/lib/python3.5/site-packages (from matplotlib)
Requirement already satisfied (use --upgrade to upgrade): numpy>=1.6 in /Users/mercybenzaquen/.virtualenvs/Homework8/lib/python3.5/site-packages (from matplotlib)
Requirement already satisfied (use --upgrade to upgrade): pytz in /Users/mercybenzaquen/.virtualenvs/Homework8/lib/python3.5/site-packages (from matplotlib)
Requirement already satisfied (use --upgrade to upgrade): six in /Users/mercybenzaquen/.virtualenvs/Homework8/lib/python3.5/site-packages (from cycler->matplotlib)

In [3]:
import pandas as pd
import matplotlib.pyplot as plt
%matplotlib inline


/Users/mercybenzaquen/.virtualenvs/Homework8/lib/python3.5/site-packages/matplotlib/__init__.py:1035: UserWarning: Duplicate key in file "/Users/mercybenzaquen/.matplotlib/matplotlibrc", line #2
  (fname, cnt))

Open your dataset up using pandas in a Jupyter notebook


In [4]:
df = pd.read_csv("mass_shootings_2015.csv", error_bad_lines=False)

Do a .head() to get a feel for your data


In [5]:
df.head()


Out[5]:
Incident Date State City Or County Address # Killed # Injured Operations
0 December 31, 2015 Louisiana New Orleans 1900 Block of Amelia Street 0 6 NaN
1 December 27, 2015 Tennessee Jackson North Parkway 0 4 NaN
2 December 26, 2015 Pennsylvania Philadelphia 4210 Macalester St 0 4 NaN
3 December 25, 2015 Florida Jacksonville Franklin and Odessa 0 4 NaN
4 December 25, 2015 Alabama Mobile 785 Schillinger Rd S 0 4 NaN

Write down 12 questions to ask your data, or 12 things to hunt for in the data

1)How many shootings in total in USA in 2015?


In [14]:
df.tail(1) #each row is an incident. There were a total of 330 mass shootings in 2015 according to shootingtracker.


Out[14]:
Incident Date State City Or County Address # Killed # Injured Operations
330 January 1, 2015 Tennessee Memphis Interstate 240 and Poplar Avenue 0 5 NaN

2)How many shootings in each state?


In [17]:
df['State'].value_counts()


Out[17]:
California              28
Illinois                25
Florida                 24
New York                21
Georgia                 20
Texas                   19
Pennsylvania            15
Louisiana               14
Ohio                    14
Maryland                13
North Carolina          12
Missouri                11
Tennessee               11
South Carolina          11
Michigan                10
Indiana                 10
New Jersey               9
Arizona                  6
Massachusetts            5
Minnesota                5
Virginia                 5
Alabama                  4
Kentucky                 4
Oklahoma                 4
Wisconsin                3
Colorado                 3
Nebraska                 3
District of Columbia     2
Connecticut              2
Mississippi              2
Iowa                     2
New Mexico               2
Oregon                   2
Arkansas                 2
Kansas                   1
Montana                  1
Vermont                  1
Rhode Island             1
South Dakota             1
Delaware                 1
Nevada                   1
Washington               1
Name: State, dtype: int64

3)How many shootings in each city?


In [27]:
df['City Or County'].value_counts()


Out[27]:
Chicago            15
Baltimore          11
New Orleans         7
Detroit             6
Indianapolis        5
Philadelphia        5
Brooklyn            5
Saint Louis         5
Houston             4
Charlotte           4
Savannah            4
Pittsburgh          4
Cleveland           4
Memphis             3
Bronx               3
Omaha               3
Stockton            3
Shreveport          3
Los Angeles         3
Minneapolis         3
Jacksonville        3
Rochester           3
Louisville          3
Columbus            3
Tulsa               3
Newark              3
Kansas City         3
Sacramento          2
Montgomery          2
Rockford            2
                   ..
Amarillo            1
Taunton             1
Gila Bend           1
Flagstaff           1
Brownsville         1
Lancaster           1
Menasha             1
Gates               1
Kinloch             1
Trenton             1
New Haven           1
Erie                1
Bakersfield         1
Raceland            1
New Port Richey     1
Seattle             1
Woonsocket          1
Rome                1
Roseburg            1
Maury City          1
Oklahoma City       1
Gary                1
Capitol Heights     1
Portsmouth          1
Bridgeport          1
Four Oaks           1
Horry (county)      1
Fayetteville        1
Lexington           1
Allapattah          1
Name: City Or County, dtype: int64

4)When and where was the incident with more casualties?


In [41]:
df.sort_values('# Killed', ascending=False).head()


Out[41]:
Incident Date State City Or County Address # Killed # Injured Operations
18 December 2, 2015 California San Bernardino 1365 South Waterman Avenue 16 19 NaN
66 October 1, 2015 Oregon Roseburg 1140 Umpqua College Rd 10 9 NaN
196 June 17, 2015 South Carolina Charleston 110 Calhoun Street 9 0 NaN
236 May 17, 2015 Texas Waco 4671 S Jack Kultgen Expy 9 18 NaN
129 August 8, 2015 Texas Houston 2211 Falling Oaks 8 0 NaN

4)How many incidents with no death? List them


In [49]:
incident_no_death = df['# Killed'] == 0
incident_no_death.value_counts()


Out[49]:
False    174
True     157
Name: # Killed, dtype: int64

In [50]:
df[df['# Killed'] == 0]


Out[50]:
Incident Date State City Or County Address # Killed # Injured Operations
0 December 31, 2015 Louisiana New Orleans 1900 Block of Amelia Street 0 6 NaN
1 December 27, 2015 Tennessee Jackson North Parkway 0 4 NaN
2 December 26, 2015 Pennsylvania Philadelphia 4210 Macalester St 0 4 NaN
3 December 25, 2015 Florida Jacksonville Franklin and Odessa 0 4 NaN
4 December 25, 2015 Alabama Mobile 785 Schillinger Rd S 0 4 NaN
5 December 21, 2015 California San Leandro 14600 block of East 14th Street 0 4 NaN
8 December 20, 2015 Florida Miami-dade (county) Northeast Seventh Avenue and Northeast 166th S... 0 4 NaN
11 December 13, 2015 California Huntington Beach 17000 block of Keelson Lane 0 4 NaN
12 December 12, 2015 Georgia Savannah Whitaker Street 0 4 NaN
14 December 11, 2015 Pennsylvania Pittsburgh (Mount Oliver) 200 Block of Brownsville Road 0 4 NaN
20 November 29, 2015 Illinois Kankakee 648 E. Court St 0 5 NaN
23 November 24, 2015 South Carolina Horry (county) 1321 Colletta Court 0 4 NaN
25 November 23, 2015 Minnesota Minneapolis Morgan Avenue North 0 5 NaN
26 November 22, 2015 Texas Brownsville 1800 Block of FM 802 0 4 NaN
27 November 22, 2015 Washington Seattle Broadway and Pike 0 4 NaN
28 November 22, 2015 Louisiana New Orleans 1900 block of Gallier Street 0 17 NaN
29 November 22, 2015 New York Newburgh 203 Broadway 0 5 NaN
31 November 22, 2015 Illinois Chicago 4100 block of West Roosevelt 0 4 NaN
34 November 18, 2015 California Fresno California Avenue and Martin Luther King Jr. B... 0 5 NaN
36 November 15, 2015 Pennsylvania Philadelphia 5600 block of Blakemore Street 0 4 NaN
38 November 14, 2015 Pennsylvania Johnstown 1159 Main St 0 4 NaN
42 November 8, 2015 Michigan Warren 13859 8 Mile Road 0 4 NaN
44 November 6, 2015 California Bakersfield 1000 block of Feliz Drive 0 4 NaN
48 October 27, 2015 Texas Fort Worth 1700 Block of Southcrest Drive 0 5 NaN
49 October 26, 2015 Indiana Evansville 711 E Virginia St 0 5 NaN
50 October 25, 2015 North Carolina Four Oaks 2339 Stricklands Crossroads Road 0 5 NaN
52 October 25, 2015 District of Columbia Washington 4300 block of Wheeler Road SE 0 5 NaN
53 October 24, 2015 South Carolina Bamberg 682 Dixie Ave. 0 4 NaN
55 October 19, 2015 Illinois Calumet City 300 Campbell Avenue 0 6 NaN
56 October 18, 2015 Louisiana New Orleans 2600 block of Caffin Avenue 0 4 NaN
... ... ... ... ... ... ... ...
245 May 7, 2015 Ohio Cincinnati 2300 block of Baltimore Avenue 0 4 NaN
247 May 3, 2015 Indiana South Bend 1600 block of South William Street 0 4 NaN
249 May 3, 2015 Texas Houston San Jacinto at Elgin 0 6 NaN
250 May 3, 2015 New York Bronx University Avenue 0 4 NaN
255 April 25, 2015 New Jersey Trenton Wood Street 0 4 NaN
258 April 19, 2015 Virginia Richmond 200 block of West Hill Street 0 4 NaN
259 April 18, 2015 Pennsylvania Williamsport 300 block of Pine Street 0 5 NaN
260 April 18, 2015 Alabama Montgomery 1800 block of Gibbs Court 0 5 NaN
262 April 18, 2015 North Carolina Charlotte Bost Street 0 4 NaN
268 April 5, 2015 Indiana Indianapolis 5000 block of Wildflower Court 0 5 NaN
269 April 5, 2015 Michigan Benton Harbor 1000 block of Blossom Lane 0 4 NaN
270 April 3, 2015 Florida Daytona Beach 300 block of Henry Butts Drive 0 4 NaN
271 April 2, 2015 Maryland Baltimore 1900 block of West Lanvale Street 0 5 NaN
272 March 27, 2015 Florida Panama City Beach 5312 Thomas Drive 0 7 NaN
273 March 26, 2015 Texas Amarillo 3100 block of Redwood 0 4 NaN
277 March 21, 2015 Florida Tampa 1802 Seventh Ave 0 4 NaN
282 March 15, 2015 California Compton 2700 block of West Alondra Boulevard 0 4 NaN
283 March 14, 2015 Georgia Atlanta 2900 block of Delmar Lane 0 5 NaN
284 March 14, 2015 California Coachella 84000 block of Bagdad Avenue 0 4 NaN
286 March 10, 2015 Georgia Columbus 3023 Victory Drive 0 5 NaN
290 March 1, 2015 Florida Orange County 4900 block of Steyr Street 0 4 NaN
297 February 22, 2015 South Carolina Charleston 4224 Dorchester Road 0 4 NaN
298 February 20, 2015 California Sacramento 1417 R Street 0 4 NaN
300 February 15, 2015 California Long Beach 200 block of W. 14th Street 0 5 NaN
302 February 8, 2015 Tennessee Maury City 251 Dupree Road 0 6 NaN
306 February 1, 2015 New York Syracuse 1217 West Fayette Street 0 6 NaN
313 January 23, 2015 Massachusetts Boston 954 Parker Street 0 6 NaN
317 January 13, 2015 Virginia Portsmouth 4100 block of Portsmouth Boulevard 0 5 NaN
321 January 11, 2015 California San Jose 3840 Monterey Hwy 0 5 NaN
330 January 1, 2015 Tennessee Memphis Interstate 240 and Poplar Avenue 0 5 NaN

157 rows × 7 columns

5)How many incidents with the same number of killed and injured


In [51]:
killed = df['# Killed']
injured =df['# Injured']

same_number_of_killed_and_injured = killed == injured

In [52]:
df[same_number_of_killed_and_injured]


Out[52]:
Incident Date State City Or County Address # Killed # Injured Operations
22 November 27, 2015 California Sacramento 7900 block of Florin Road 2 2 NaN
40 November 9, 2015 Indiana Indianapolis 400 block of North Beville Ave 2 2 NaN
105 August 27, 2015 California Salinas 928 Blanco Circle 2 2 NaN
107 August 26, 2015 Florida West Palm Beach 800 block of 19th Street 2 2 NaN
115 August 20, 2015 Texas Grulla (La Grulla) FM 2360 2 2 NaN
156 July 18, 2015 Louisiana Baton Rouge 300 Block of Brice Street 2 2 NaN
226 May 26, 2015 Louisiana New Orleans 6700 Block of Tara Lane 2 2 NaN
232 May 23, 2015 California Fresno 2400 block of South 9th Street 2 2 NaN
254 April 27, 2015 Arizona Gila Bend State Route 85 2 2 NaN
294 February 25, 2015 Texas Houston Mallow St. 3 3 NaN
305 February 5, 2015 Ohio Beachwood (Warrensville Heights) Harvard Road 3 3 NaN
316 January 16, 2015 California Oakland 105th and Edes 2 2 NaN
318 January 13, 2015 Illinois Rockford 700 block of Oakley Avenue 2 2 NaN
322 January 10, 2015 Kansas Wichita 4859 E Harry Street 2 2 NaN

6)The most shootings occured in this date:


In [55]:
df['Incident Date'].value_counts()


Out[55]:
November 22, 2015     6
April 18, 2015        5
May 3, 2015           5
August 2, 2015        5
July 4, 2015          5
July 15, 2015         5
June 13, 2015         5
April 5, 2015         4
September 12, 2015    4
September 28, 2015    4
May 24, 2015          4
May 31, 2015          4
July 18, 2015         4
September 5, 2015     4
September 20, 2015    3
June 14, 2015         3
June 28, 2015         3
July 5, 2015          3
May 10, 2015          3
October 10, 2015      3
August 26, 2015       3
August 8, 2015        3
February 22, 2015     3
January 11, 2015      3
October 25, 2015      3
August 16, 2015       3
December 20, 2015     3
August 15, 2015       3
May 28, 2015          3
June 20, 2015         3
                     ..
December 8, 2015      1
January 1, 2015       1
August 19, 2015       1
November 7, 2015      1
January 19, 2015      1
September 24, 2015    1
September 11, 2015    1
May 4, 2015           1
October 27, 2015      1
March 27, 2015        1
May 20, 2015          1
May 26, 2015          1
February 7, 2015      1
July 2, 2015          1
September 15, 2015    1
October 12, 2015      1
July 21, 2015         1
October 18, 2015      1
March 24, 2015        1
March 22, 2015        1
January 7, 2015       1
June 3, 2015          1
February 20, 2015     1
March 21, 2015        1
May 25, 2015          1
January 9, 2015       1
May 1, 2015           1
December 27, 2015     1
November 2, 2015      1
December 12, 2015     1
Name: Incident Date, dtype: int64

7)Where were the shootings during Nov 22, 2015?


In [59]:
deadliest_date= df['Incident Date'] == 'November 22, 2015'
df[deadliest_date]


Out[59]:
Incident Date State City Or County Address # Killed # Injured Operations
26 November 22, 2015 Texas Brownsville 1800 Block of FM 802 0 4 NaN
27 November 22, 2015 Washington Seattle Broadway and Pike 0 4 NaN
28 November 22, 2015 Louisiana New Orleans 1900 block of Gallier Street 0 17 NaN
29 November 22, 2015 New York Newburgh 203 Broadway 0 5 NaN
30 November 22, 2015 South Carolina North Charleston Park Circle 1 3 NaN
31 November 22, 2015 Illinois Chicago 4100 block of West Roosevelt 0 4 NaN

8)Was there more than one shooting in a single address?


In [79]:
addresses = df['Address'].value_counts()
addresses.sort_values(ascending=False)


Out[79]:
2300 block of Baltimore Avenue           2
98 Dwight Street                         1
Piety and Treasure street                1
1921 Oakridge                            1
36 Woodward Street                       1
Smiley Court                             1
748 N Madison St                         1
100 block of Roosevelt Avenue            1
1910 South Pine Avenue                   1
3500 block of Hearne Avenue              1
2405 North Flora                         1
13859 8 Mile Road                        1
700 block of Oakley Avenue               1
3600 block of Bosworth Road              1
3500 block of West Garrison Boulevard    1
1365 Flatbush Ave                        1
Morgan Avenue North                      1
1800 block of North Kingston             1
Channel Drive                            1
700 block of East Hilton Street          1
600 block of Highway 279                 1
Wells Highway                            1
14600 block of East 14th Street          1
Wood Street                              1
5400 Reisterstown Road                   1
928 Blanco Circle                        1
1321 Colletta Court                      1
400 block of North Beville Ave           1
500 block of Se 69th St                  1
84000 block of Bagdad Avenue             1
                                        ..
1st Ave. and N. 5th St.                  1
9200 block of Memorial                   1
4051 Amnicola Highway                    1
90 block of S. Terrace Avenue            1
University Avenue                        1
4100 block of West Roosevelt             1
4671 S Jack Kultgen Expy                 1
40th Street and Pennsylvania Avenue      1
4200 block of Market Street              1
1400 block of North Market Street        1
200 block of West 29th Street            1
FM 2360                                  1
400 Block of Morgan Street               1
300 block of Henry Butts Drive           1
600 block of Northwest 177th Street      1
9300 block of Sunrise                    1
Gratiot and Loretto                      1
2800 block of Saunders Street            1
300 block of West 42nd Street            1
2110 Madison Ave                         1
Interstate 240 and Poplar Avenue         1
3182 Airport Road                        1
2700 block of Hinson Drive               1
North 108th Street and Military Road     1
6800 block of Fieldvale Place            1
500 Genesee Street                       1
36705 379th Street                       1
Bayaud and Bannock                       1
Weir Street                              1
9222 Ardwick Ardmore Road                1
Name: Address, dtype: int64

9) How many people in total died in the two shootings at 2300 block of Baltimore Avenue? Is it the deadliest address?


In [99]:
two_shootings_same_address= df['Address'] == '2300 block of Baltimore Avenue'
df[two_shootings_same_address]


Out[99]:
Incident Date State City Or County Address # Killed # Injured Operations
15 December 8, 2015 Ohio Cincinnati (Fairmount) 2300 block of Baltimore Avenue 1 3 NaN
245 May 7, 2015 Ohio Cincinnati 2300 block of Baltimore Avenue 0 4 NaN

It is not the deadliest address, The deadliest address is:


In [107]:
df.sort_values('# Killed', ascending=False).head()


Out[107]:
Incident Date State City Or County Address # Killed # Injured Operations
18 December 2, 2015 California San Bernardino 1365 South Waterman Avenue 16 19 NaN
66 October 1, 2015 Oregon Roseburg 1140 Umpqua College Rd 10 9 NaN
196 June 17, 2015 South Carolina Charleston 110 Calhoun Street 9 0 NaN
236 May 17, 2015 Texas Waco 4671 S Jack Kultgen Expy 9 18 NaN
129 August 8, 2015 Texas Houston 2211 Falling Oaks 8 0 NaN

10) How many incidents were the #Killed was greater than the #Injured?


In [122]:
killed = df['# Killed']
injured =df['# Injured']

greater_number_of_killed_than_injured = killed > injured
greater_number_of_killed_than_injured.value_counts()


Out[122]:
False    295
True      36
dtype: int64

These incidents were:


In [123]:
df[greater_number_of_killed_than_injured]


Out[123]:
Incident Date State City Or County Address # Killed # Injured Operations
24 November 23, 2015 Ohio Columbus 90 block of S. Terrace Avenue 4 1 NaN
35 November 16, 2015 Alabama Cherokee (county) 1400 block of County Road 664 3 1 NaN
37 November 15, 2015 Texas Tennessee Colony 800 Block of County Road 2217 5 0 NaN
39 November 13, 2015 Florida Jacksonville 1300 block of South Shirley Oaks Drive 4 1 NaN
46 November 2, 2015 South Carolina Pendleton 2217 Refuge Road 4 0 NaN
66 October 1, 2015 Oregon Roseburg 1140 Umpqua College Rd 10 9 NaN
68 September 28, 2015 Illinois Chicago 300 block of West 42nd Street 3 2 NaN
83 September 17, 2015 South Dakota Platte 36705 379th Street 6 0 NaN
92 September 10, 2015 Minnesota Excelsior (Greenwood) Channel Drive 5 0 NaN
102 August 29, 2015 Tennessee Bristol 618 Henson Road 3 2 NaN
112 August 22, 2015 New Mexico Roswell 302 East Reed Street 3 1 NaN
129 August 8, 2015 Texas Houston 2211 Falling Oaks 8 0 NaN
130 August 7, 2015 Vermont Barre (Berlin) 3182 Airport Road 4 0 NaN
147 July 22, 2015 Georgia Suwanee 5500 block of Old Atlanta Road 5 0 NaN
159 July 16, 2015 Tennessee Chattanooga 4051 Amnicola Highway 6 2 NaN
165 July 15, 2015 South Carolina Holly Hill 7050 Old State Road 4 1 NaN
172 July 7, 2015 Maryland Baltimore 900 block of West Fayette Street 3 1 NaN
196 June 17, 2015 South Carolina Charleston 110 Calhoun Street 9 0 NaN
203 June 13, 2015 Ohio Columbus 1623 E. Hudson Street 4 1 NaN
212 June 7, 2015 Montana Deer Lodge Boulder Creek Road 5 0 NaN
217 June 3, 2015 New York Wyandanch Davidson Street 3 1 NaN
218 May 31, 2015 Ohio Cleveland 16209 block of Laverne Avenue 3 1 NaN
221 May 31, 2015 Georgia Conyers 4669 Bell Road SE 3 2 NaN
241 May 12, 2015 Arizona Tucson 800 block of West Calle Medina Road 5 0 NaN
248 May 3, 2015 Wisconsin Menasha North Lake Street 4 1 NaN
264 April 16, 2015 Arizona Phoenix 4300 block of East Anderson Drive 5 0 NaN
274 March 24, 2015 Indiana Indianapolis 3100 block of North Harding Street 4 0 NaN
293 February 26, 2015 Missouri Tyrone 18279 Highway H 8 1 NaN
295 February 22, 2015 Texas Killeen 1706 Godman St. 4 1 NaN
296 February 22, 2015 Georgia Clarkesville 281 Lower Pond Court 3 2 NaN
301 February 9, 2015 Florida New Port Richey 9552 Adler Street 3 1 NaN
303 February 7, 2015 Georgia Douglasville 3640 Willow Tree Circle 5 2 NaN
308 January 31, 2015 Georgia Lagrange 100 block of Woodstream Trail 4 0 NaN
311 January 24, 2015 New York Arverne (Queens) 231-11 148th Avenue 4 1 NaN
323 January 9, 2015 California San Francisco Laguna and Page streets 4 0 NaN
328 January 4, 2015 Texas Dallas 2000 block of Ben Hur St. 3 1 NaN

10) How many incidents were the #Injured was greater than the #Killed?


In [124]:
greater_number_of_injured_than_killed = injured > killed
greater_number_of_injured_than_killed.value_counts()


Out[124]:
True     281
False     50
dtype: int64

These incidents were:


In [125]:
df[greater_number_of_injured_than_killed]


Out[125]:
Incident Date State City Or County Address # Killed # Injured Operations
0 December 31, 2015 Louisiana New Orleans 1900 Block of Amelia Street 0 6 NaN
1 December 27, 2015 Tennessee Jackson North Parkway 0 4 NaN
2 December 26, 2015 Pennsylvania Philadelphia 4210 Macalester St 0 4 NaN
3 December 25, 2015 Florida Jacksonville Franklin and Odessa 0 4 NaN
4 December 25, 2015 Alabama Mobile 785 Schillinger Rd S 0 4 NaN
5 December 21, 2015 California San Leandro 14600 block of East 14th Street 0 4 NaN
6 December 20, 2015 North Carolina Wilmington 11th and Castle Street 1 4 NaN
7 December 20, 2015 Florida Miami (Goulds) 21630 Southwest 120th Avenue 1 4 NaN
8 December 20, 2015 Florida Miami-dade (county) Northeast Seventh Avenue and Northeast 166th S... 0 4 NaN
9 December 14, 2015 Illinois Lovejoy (Brooklyn) 307 Jefferson St 1 3 NaN
10 December 13, 2015 California Los Angeles 5550 S. Flower Street 1 3 NaN
11 December 13, 2015 California Huntington Beach 17000 block of Keelson Lane 0 4 NaN
12 December 12, 2015 Georgia Savannah Whitaker Street 0 4 NaN
13 December 11, 2015 Maryland Baltimore 5100 block of Park Heights Avenue 1 3 NaN
14 December 11, 2015 Pennsylvania Pittsburgh (Mount Oliver) 200 Block of Brownsville Road 0 4 NaN
15 December 8, 2015 Ohio Cincinnati (Fairmount) 2300 block of Baltimore Avenue 1 3 NaN
16 December 6, 2015 Louisiana Raceland Market Street 1 3 NaN
17 December 6, 2015 Nebraska Omaha North 108th Street and Military Road 2 3 NaN
18 December 2, 2015 California San Bernardino 1365 South Waterman Avenue 16 19 NaN
19 December 2, 2015 Georgia Savannah 100 block of West 33rd Street 1 3 NaN
20 November 29, 2015 Illinois Kankakee 648 E. Court St 0 5 NaN
21 November 27, 2015 Colorado Colorado Springs 3480 Centennial Blvd 3 9 NaN
23 November 24, 2015 South Carolina Horry (county) 1321 Colletta Court 0 4 NaN
25 November 23, 2015 Minnesota Minneapolis Morgan Avenue North 0 5 NaN
26 November 22, 2015 Texas Brownsville 1800 Block of FM 802 0 4 NaN
27 November 22, 2015 Washington Seattle Broadway and Pike 0 4 NaN
28 November 22, 2015 Louisiana New Orleans 1900 block of Gallier Street 0 17 NaN
29 November 22, 2015 New York Newburgh 203 Broadway 0 5 NaN
30 November 22, 2015 South Carolina North Charleston Park Circle 1 3 NaN
31 November 22, 2015 Illinois Chicago 4100 block of West Roosevelt 0 4 NaN
... ... ... ... ... ... ... ...
287 March 9, 2015 Illinois Chicago 200 block of West 105th 1 3 NaN
288 March 8, 2015 South Carolina Seneca Wells Highway 1 3 NaN
289 March 4, 2015 California San Bernardino 190 block of West Club Center Drive 2 5 NaN
290 March 1, 2015 Florida Orange County 4900 block of Steyr Street 0 4 NaN
291 March 1, 2015 Michigan Detroit 9855 Chalmers St 1 5 NaN
292 February 28, 2015 Maryland Baltimore 4300 block of Welbourne Road 1 3 NaN
297 February 22, 2015 South Carolina Charleston 4224 Dorchester Road 0 4 NaN
298 February 20, 2015 California Sacramento 1417 R Street 0 4 NaN
299 February 17, 2015 Arkansas Little Rock 7900 Scott Hamilton 1 3 NaN
300 February 15, 2015 California Long Beach 200 block of W. 14th Street 0 5 NaN
302 February 8, 2015 Tennessee Maury City 251 Dupree Road 0 6 NaN
304 February 6, 2015 Oklahoma Tulsa 1219 N. Sheridan Road 1 4 NaN
306 February 1, 2015 New York Syracuse 1217 West Fayette Street 0 6 NaN
307 February 1, 2015 New York New York (Manhattan) 3345 Broadway 1 4 NaN
309 January 28, 2015 Georgia Dekalb County 1600 block of Panola Road 1 3 NaN
310 January 26, 2015 California Stockton 1500 block of E. 9th Street 1 3 NaN
312 January 24, 2015 Nebraska Omaha 3402 Parker St 3 5 NaN
313 January 23, 2015 Massachusetts Boston 954 Parker Street 0 6 NaN
314 January 20, 2015 Tennessee Clarksville 321 Lansinger Lane 1 3 NaN
315 January 19, 2015 Texas San Antonio 1000 block of Gibbs St. 2 5 NaN
317 January 13, 2015 Virginia Portsmouth 4100 block of Portsmouth Boulevard 0 5 NaN
319 January 11, 2015 North Carolina Hope Mills 1900 block of Gumberry Road 2 5 NaN
320 January 11, 2015 Florida Lakeland 7665 Chase Road 1 3 NaN
321 January 11, 2015 California San Jose 3840 Monterey Hwy 0 5 NaN
324 January 8, 2015 Massachusetts Boston 104 Harrishof Street 1 3 NaN
325 January 7, 2015 Tennessee Chattanooga 773 West Main Street 1 3 NaN
326 January 6, 2015 Florida Miami 1300 block of NW 62nd Street 1 3 NaN
327 January 4, 2015 Virginia Roanoke 3634 Shenandoah Ave NW 2 4 NaN
329 January 2, 2015 Georgia Savannah 500 block of W. 54th Street 1 4 NaN
330 January 1, 2015 Tennessee Memphis Interstate 240 and Poplar Avenue 0 5 NaN

281 rows × 7 columns

11)Since California was the state with more shootings, list all the information for the shootings in CA.


In [127]:
California = df['State'] == "California"
df[California]


Out[127]:
Incident Date State City Or County Address # Killed # Injured Operations
5 December 21, 2015 California San Leandro 14600 block of East 14th Street 0 4 NaN
10 December 13, 2015 California Los Angeles 5550 S. Flower Street 1 3 NaN
11 December 13, 2015 California Huntington Beach 17000 block of Keelson Lane 0 4 NaN
18 December 2, 2015 California San Bernardino 1365 South Waterman Avenue 16 19 NaN
22 November 27, 2015 California Sacramento 7900 block of Florin Road 2 2 NaN
34 November 18, 2015 California Fresno California Avenue and Martin Luther King Jr. B... 0 5 NaN
44 November 6, 2015 California Bakersfield 1000 block of Feliz Drive 0 4 NaN
105 August 27, 2015 California Salinas 928 Blanco Circle 2 2 NaN
110 August 23, 2015 California Modesto 1100 block of Kansas Avenue 1 7 NaN
121 August 15, 2015 California Los Angeles 57th Street and South Normandie Avenue 0 4 NaN
123 August 10, 2015 California Long Beach 1700 block of East 10th Street 0 4 NaN
153 July 18, 2015 California San Diego 200 block of South Bancroft Street 0 4 NaN
154 July 18, 2015 California Santa Paula Ojai-Santa Paula Street 0 5 NaN
167 July 13, 2015 California Norwalk 11959 162nd Street 0 4 NaN
168 July 13, 2015 California Stockton 400 block of McCloud Avenue 1 4 NaN
210 June 10, 2015 California Los Angeles South Vermont Avenue and West 88th Street 1 3 NaN
222 May 30, 2015 California San Diego 4200 block of Market Street 0 4 NaN
232 May 23, 2015 California Fresno 2400 block of South 9th Street 2 2 NaN
281 March 17, 2015 California Stockton 748 N Madison St 3 4 NaN
282 March 15, 2015 California Compton 2700 block of West Alondra Boulevard 0 4 NaN
284 March 14, 2015 California Coachella 84000 block of Bagdad Avenue 0 4 NaN
289 March 4, 2015 California San Bernardino 190 block of West Club Center Drive 2 5 NaN
298 February 20, 2015 California Sacramento 1417 R Street 0 4 NaN
300 February 15, 2015 California Long Beach 200 block of W. 14th Street 0 5 NaN
310 January 26, 2015 California Stockton 1500 block of E. 9th Street 1 3 NaN
316 January 16, 2015 California Oakland 105th and Edes 2 2 NaN
321 January 11, 2015 California San Jose 3840 Monterey Hwy 0 5 NaN
323 January 9, 2015 California San Francisco Laguna and Page streets 4 0 NaN

12)List all shootings where the number of Killed was 0 and the number of Injured greater than 3


In [129]:
none_killed = df['# Killed'] == 0
more_than_3_injured = df['# Injured'] > 3
df[(none_killed & more_than_3_injured)]


Out[129]:
Incident Date State City Or County Address # Killed # Injured Operations
0 December 31, 2015 Louisiana New Orleans 1900 Block of Amelia Street 0 6 NaN
1 December 27, 2015 Tennessee Jackson North Parkway 0 4 NaN
2 December 26, 2015 Pennsylvania Philadelphia 4210 Macalester St 0 4 NaN
3 December 25, 2015 Florida Jacksonville Franklin and Odessa 0 4 NaN
4 December 25, 2015 Alabama Mobile 785 Schillinger Rd S 0 4 NaN
5 December 21, 2015 California San Leandro 14600 block of East 14th Street 0 4 NaN
8 December 20, 2015 Florida Miami-dade (county) Northeast Seventh Avenue and Northeast 166th S... 0 4 NaN
11 December 13, 2015 California Huntington Beach 17000 block of Keelson Lane 0 4 NaN
12 December 12, 2015 Georgia Savannah Whitaker Street 0 4 NaN
14 December 11, 2015 Pennsylvania Pittsburgh (Mount Oliver) 200 Block of Brownsville Road 0 4 NaN
20 November 29, 2015 Illinois Kankakee 648 E. Court St 0 5 NaN
23 November 24, 2015 South Carolina Horry (county) 1321 Colletta Court 0 4 NaN
25 November 23, 2015 Minnesota Minneapolis Morgan Avenue North 0 5 NaN
26 November 22, 2015 Texas Brownsville 1800 Block of FM 802 0 4 NaN
27 November 22, 2015 Washington Seattle Broadway and Pike 0 4 NaN
28 November 22, 2015 Louisiana New Orleans 1900 block of Gallier Street 0 17 NaN
29 November 22, 2015 New York Newburgh 203 Broadway 0 5 NaN
31 November 22, 2015 Illinois Chicago 4100 block of West Roosevelt 0 4 NaN
34 November 18, 2015 California Fresno California Avenue and Martin Luther King Jr. B... 0 5 NaN
36 November 15, 2015 Pennsylvania Philadelphia 5600 block of Blakemore Street 0 4 NaN
38 November 14, 2015 Pennsylvania Johnstown 1159 Main St 0 4 NaN
42 November 8, 2015 Michigan Warren 13859 8 Mile Road 0 4 NaN
44 November 6, 2015 California Bakersfield 1000 block of Feliz Drive 0 4 NaN
48 October 27, 2015 Texas Fort Worth 1700 Block of Southcrest Drive 0 5 NaN
49 October 26, 2015 Indiana Evansville 711 E Virginia St 0 5 NaN
50 October 25, 2015 North Carolina Four Oaks 2339 Stricklands Crossroads Road 0 5 NaN
52 October 25, 2015 District of Columbia Washington 4300 block of Wheeler Road SE 0 5 NaN
53 October 24, 2015 South Carolina Bamberg 682 Dixie Ave. 0 4 NaN
55 October 19, 2015 Illinois Calumet City 300 Campbell Avenue 0 6 NaN
56 October 18, 2015 Louisiana New Orleans 2600 block of Caffin Avenue 0 4 NaN
... ... ... ... ... ... ... ...
245 May 7, 2015 Ohio Cincinnati 2300 block of Baltimore Avenue 0 4 NaN
247 May 3, 2015 Indiana South Bend 1600 block of South William Street 0 4 NaN
249 May 3, 2015 Texas Houston San Jacinto at Elgin 0 6 NaN
250 May 3, 2015 New York Bronx University Avenue 0 4 NaN
255 April 25, 2015 New Jersey Trenton Wood Street 0 4 NaN
258 April 19, 2015 Virginia Richmond 200 block of West Hill Street 0 4 NaN
259 April 18, 2015 Pennsylvania Williamsport 300 block of Pine Street 0 5 NaN
260 April 18, 2015 Alabama Montgomery 1800 block of Gibbs Court 0 5 NaN
262 April 18, 2015 North Carolina Charlotte Bost Street 0 4 NaN
268 April 5, 2015 Indiana Indianapolis 5000 block of Wildflower Court 0 5 NaN
269 April 5, 2015 Michigan Benton Harbor 1000 block of Blossom Lane 0 4 NaN
270 April 3, 2015 Florida Daytona Beach 300 block of Henry Butts Drive 0 4 NaN
271 April 2, 2015 Maryland Baltimore 1900 block of West Lanvale Street 0 5 NaN
272 March 27, 2015 Florida Panama City Beach 5312 Thomas Drive 0 7 NaN
273 March 26, 2015 Texas Amarillo 3100 block of Redwood 0 4 NaN
277 March 21, 2015 Florida Tampa 1802 Seventh Ave 0 4 NaN
282 March 15, 2015 California Compton 2700 block of West Alondra Boulevard 0 4 NaN
283 March 14, 2015 Georgia Atlanta 2900 block of Delmar Lane 0 5 NaN
284 March 14, 2015 California Coachella 84000 block of Bagdad Avenue 0 4 NaN
286 March 10, 2015 Georgia Columbus 3023 Victory Drive 0 5 NaN
290 March 1, 2015 Florida Orange County 4900 block of Steyr Street 0 4 NaN
297 February 22, 2015 South Carolina Charleston 4224 Dorchester Road 0 4 NaN
298 February 20, 2015 California Sacramento 1417 R Street 0 4 NaN
300 February 15, 2015 California Long Beach 200 block of W. 14th Street 0 5 NaN
302 February 8, 2015 Tennessee Maury City 251 Dupree Road 0 6 NaN
306 February 1, 2015 New York Syracuse 1217 West Fayette Street 0 6 NaN
313 January 23, 2015 Massachusetts Boston 954 Parker Street 0 6 NaN
317 January 13, 2015 Virginia Portsmouth 4100 block of Portsmouth Boulevard 0 5 NaN
321 January 11, 2015 California San Jose 3840 Monterey Hwy 0 5 NaN
330 January 1, 2015 Tennessee Memphis Interstate 240 and Poplar Avenue 0 5 NaN

157 rows × 7 columns

13)Create a new column with the total number of victims (killed + injured)


In [269]:
df['Total Victims'] = df['# Killed'] + df['# Injured']
df.head()


Out[269]:
Incident Date State City Or County Address # Killed # Injured Operations Total Victims
0 December 31, 2015 Louisiana New Orleans 1900 Block of Amelia Street 0 6 NaN 6
1 December 27, 2015 Tennessee Jackson North Parkway 0 4 NaN 4
2 December 26, 2015 Pennsylvania Philadelphia 4210 Macalester St 0 4 NaN 4
3 December 25, 2015 Florida Jacksonville Franklin and Odessa 0 4 NaN 4
4 December 25, 2015 Alabama Mobile 785 Schillinger Rd S 0 4 NaN 4

Make three charts with your dataset


In [175]:
plt.style.available


Out[175]:
['seaborn-ticks',
 'seaborn-whitegrid',
 'seaborn-talk',
 'classic',
 'bmh',
 'seaborn-muted',
 'seaborn-pastel',
 'seaborn-paper',
 'fivethirtyeight',
 'seaborn-bright',
 'seaborn-notebook',
 'dark_background',
 'seaborn-deep',
 'grayscale',
 'seaborn-poster',
 'ggplot',
 'seaborn-darkgrid',
 'seaborn-colorblind',
 'seaborn-white',
 'seaborn-dark-palette',
 'seaborn-dark']

In [197]:
plt.style.use('ggplot')

In [240]:
plt.style.use('ggplot')
df.head(30).sort_values(by='# Killed',ascending=True).plot(kind='barh', title ="# Killed by State", x='State', y='# Killed', color = 'r')


Out[240]:
<matplotlib.axes._subplots.AxesSubplot at 0x11acf1f98>

In [241]:
plt.style.use('ggplot')
df.head(30).sort_values(by='# Injured',ascending=True).plot(kind='barh',title ="# Injured by State", x='State', y='# Injured', color = 'r')


Out[241]:
<matplotlib.axes._subplots.AxesSubplot at 0x11b0c4940>

In [257]:
graph_injured_killed = df[['# Killed','# Injured']].head(40).plot(kind='bar', title ="# Killed vs # Injured", legend=True, fontsize=14)
graph_injured_killed.set_ylabel("Number of Killed/Injured",fontsize=12)
graph_injured_killed.set_xlabel("Incident",fontsize=12)

#I could not figure out how to sort it.


Out[257]:
<matplotlib.text.Text at 0x11bde8a20>

In [210]:
plt.style.use('ggplot')
df.head().plot(kind='pie', y='# Killed', labels=df['State'].head(), legend=False)

#This graphic appears blank??


Out[210]:
<matplotlib.axes._subplots.AxesSubplot at 0x113ce7eb8>

In [264]:
df.head(30).sort_values(by='# Killed',ascending=True).plot(kind='barh', title ="# Killed by City", x='City Or County', y='# Killed', color = 'r')


Out[264]:
<matplotlib.axes._subplots.AxesSubplot at 0x11da5e978>

In [261]:
df.head(30).sort_values(by='# Injured',ascending=True).plot(kind='barh', title ="# Injured by City", x='City Or County', y='# Injured', color = 'r')


Out[261]:
<matplotlib.axes._subplots.AxesSubplot at 0x11ce76908>

In [ ]:


In [ ]:


In [ ]: