The Counted (project by The Guardian to count the people killed by police in the US)

Why is this necessary?

From The Guardian's http://www.theguardian.com/us-news/ng-interactive/2015/jun/01/the-counted-police-killings-us-database "The US government has no comprehensive record of the number of people killed by law enforcement. This lack of basic data has been glaring amid the protests, riots and worldwide debate set in motion by the fatal police shooting of Michael Brown, an unarmed 18-year-old, in Ferguson, Missouri, in August 2014."


In [2]:
!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): numpy>=1.7.0 in /Users/mercybenzaquen/.virtualenvs/Homework8/lib/python3.5/site-packages (from pandas)
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): six>=1.5 in /Users/mercybenzaquen/.virtualenvs/Homework8/lib/python3.5/site-packages (from python-dateutil>=2->pandas)

In [3]:
!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): 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): numpy>=1.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): pytz in /Users/mercybenzaquen/.virtualenvs/Homework8/lib/python3.5/site-packages (from matplotlib)
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): six>=1.5 in /Users/mercybenzaquen/.virtualenvs/Homework8/lib/python3.5/site-packages (from python-dateutil->matplotlib)

In [4]:
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 [5]:
df = pd.read_csv('the-counted-2015.csv', encoding = "ISO-8859-1")

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


In [6]:
df.head()


Out[6]:
uid name age gender raceethnicity month day year streetaddress city state classification lawenforcementagency armed
0 2 Matthew Ajibade 22 Male Black January 1 2015 1050 Carl Griffin Dr Savannah GA Death in custody Chatham County Sheriff's Office No
1 4 Lewis Lembke 47 Male White January 2 2015 4505 SW Masters Loop Aloha OR Gunshot Washington County Sheriff's Office Firearm
2 7 Tim Elliott 53 Male Asian/Pacific Islander January 2 2015 600 E Island Lake Dr Shelton WA Gunshot Mason County Sheriff's Office Firearm
3 5 Michael Kocher Jr 19 Male White January 3 2015 2600 Kaumualii Hwy Kaumakani HI Struck by vehicle Kauai Police Department No
4 6 John Quintero 23 Male Hispanic/Latino January 3 2015 500 North Oliver Ave Wichita KS Gunshot Wichita Police Department No

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

1) How many people were killed by police in 2015?


In [7]:
df.tail(1) #there is one line per incident, so tail will give us the last incident.


Out[7]:
uid name age gender raceethnicity month day year streetaddress city state classification lawenforcementagency armed
1145 1170 James McBride 74 Male Black September 29 2015 110 Irving St NW Washington DC Death in custody Special police, Washington DC No

2)Who was/were the oldest person killed?


In [8]:
df.sort_values('age', ascending=False).head(10)


Out[8]:
uid name age gender raceethnicity month day year streetaddress city state classification lawenforcementagency armed
147 146 Alejandro Salazar Unknown Male Hispanic/Latino February 20 2015 1200 E Airtex Dr Houston TX Gunshot US Marshals Service, Texas Department of Crimi... Firearm
88 1051 Robert Edwards Unknown Male Unknown January 30 2015 6607 S Interstate 35 Austin TX Death in custody Austin Police Department No
1066 1089 Unknown Unknown Male Unknown December 10 2015 200 E Stetson Ave Hemet CA Gunshot Hemet Police Department Firearm
1072 1097 Unknown Unknown Male Unknown December 12 2015 698 Kenton St Aurora CO Gunshot Aurora Police Department Knife
35 37 Louis Becker 87 Male White January 14 2015 New York State Rte 23 and Cairo Junction Rd Catskill NY Struck by vehicle New York State Police No
508 504 Raymond Phillips 85 Male White June 11 2015 1000 Bear Creek Pike Columbia TN Gunshot Columbia Police Department Firearm
326 317 Richard 'Buddy' Weaver 83 Male White April 12 2015 Sleepy Hollow Dr and Misty Glen Dr Newalla OK Gunshot Oklahoma City Police Department Other
269 273 Douglas Harris 77 Male Black March 27 2015 7901 1st Ave S Birmingham AL Gunshot Birmingham Police Department Firearm
613 607 Nyal Brown 77 Male White July 13 2015 3505 Sullivant Ave Columbus OH Struck by vehicle Franklin County Sheriff's Office No
709 712 Robert Quinn 77 Male Unknown August 9 2015 101 N Main St Pittston PA Gunshot Pittston Police Department Non-lethal firearm

3)Who was/were the youngest person killed?


In [9]:
df.sort_values('age', ascending=True).head(5)


Out[9]:
uid name age gender raceethnicity month day year streetaddress city state classification lawenforcementagency armed
906 915 Jorge Tapia 15 Male Hispanic/Latino October 15 2015 SW 137th Ave and SW 280th St Homestead FL Gunshot Miami-Dade Police Department Firearm
711 710 Andre Green 15 Male Black August 10 2015 3300 N Butler Ave Indianapolis IN Gunshot Indianapolis Metropolitan Police Department Vehicle
519 514 Zane Terryn 15 Male White June 14 2015 4455 King St Cocoa FL Gunshot Brevard County Sheriff's Office Firearm
243 237 Kendre Alston 16 Male Black March 19 2015 Mount Olive Cemetery Jacksonville FL Gunshot Jacksonville Sheriff's Office Firearm
863 893 Isabella Chinchilla 16 Female White September 26 2015 US-27 Carrollton GA Struck by vehicle Georgia State Patrol No

4)What was the age average of people killed?


In [10]:
df['age'].describe()  #I could not get the average :s!

#I thought using describe I would get something like this:
#count    18617.000000
#mean        53.314841
#std         10.679143
#min         25.000000
#25%         45.400000
#50%         53.000000
#75%         60.500000
#max         98.100000
#Name: age, dtype: float64


Out[10]:
count     1146
unique      66
top         24
freq        46
Name: age, dtype: object

5)What was the state with more killings by police in 2015?


In [11]:
df['state'].value_counts()


Out[11]:
CA    211
TX    110
FL     71
AZ     44
GA     39
OK     38
OH     37
CO     32
LA     28
NC     26
NY     25
PA     24
WA     23
IL     23
NJ     23
VA     23
MO     22
NM     21
TN     21
SC     21
IN     21
MI     20
NV     19
KY     19
AL     19
MD     17
OR     17
MN     13
WI     12
WV     12
MS     12
KS     11
UT     10
MA     10
NE      9
ID      8
DC      7
WY      6
AR      5
HI      5
AK      5
IA      5
DE      4
MT      4
CT      4
NH      3
ME      2
SD      2
RI      1
VT      1
ND      1
Name: state, dtype: int64

6)What was the city with more killings by police in 2015?


In [12]:
df['city'].value_counts()


Out[12]:
Los Angeles          20
Houston              17
Las Vegas            12
Phoenix              10
Chicago              10
Indianapolis         10
Dallas                9
Miami                 9
San Francisco         9
New York              8
Columbus              8
San Antonio           8
San Diego             8
Washington            7
San Jose              7
Bakersfield           7
Denver                7
Oklahoma City         7
Austin                7
Jacksonville          6
Oakland               6
Columbia              6
Kansas City           6
Orlando               5
Fresno                5
Arlington             5
Hemet                 5
Cleveland             5
Long Beach            5
Albuquerque           5
                     ..
Sunset                1
Mesquite              1
San Bernadino         1
Muscle Shoals         1
Union                 1
Mitchell              1
Goose Creek           1
Randallstown          1
Washington County     1
Tehachapi             1
Old Town              1
Forest Grove          1
Baytown               1
Pride                 1
Kahului               1
Roslindale            1
Harmony               1
Northglenn            1
Palmdale              1
West Palm Beach       1
El Monte              1
Terre Haute           1
Fort Gibson           1
St Martinville        1
Evergreen             1
Hartford              1
Findlay               1
Syracuse              1
Levelland             1
Ville Platte          1
Name: city, dtype: int64

7)List all the incidents in Los Angeles


In [13]:
los_angeles = df['city'] == 'Los Angeles'
#df['complete_date'] = df['day'], df['year']
df[los_angeles]

#I wanted to add a new column to order the incidents chronologically (month, day, year) but I got an error saying, 
#ValueError: Length of values does not match length of index


Out[13]:
uid name age gender raceethnicity month day year streetaddress city state classification lawenforcementagency armed
11 12 Brian Pickett 26 Male Black January 6 2015 1618 E 123rd St Los Angeles CA Taser Los Angeles County Sheriff's Department No
52 52 Pablo Meza 24 Male Hispanic/Latino January 17 2015 Jesse St and Mateo St Los Angeles CA Gunshot Los Angeles Police Department Firearm
115 114 Dean Bucheit 64 Male White February 9 2015 13600 Culver Blvd Los Angeles CA Struck by vehicle Los Angeles Police Department No
175 174 Charly 'Africa' Keunang 43 Male Black March 1 2015 500 San Pedro St Los Angeles CA Gunshot Los Angeles Police Department No
214 211 Antonio Perez 32 Male Hispanic/Latino March 12 2015 2400 Flower St Los Angeles CA Gunshot Los Angeles County Sheriff's Department No
265 263 Victor Terrazas 28 Male Hispanic/Latino March 25 2015 10200 S Vermont Ave Los Angeles CA Gunshot Los Angeles County Sheriff's Department Firearm
310 305 Roberto Rodriguez 39 Male Hispanic/Latino April 8 2015 4th St and Mathews St Los Angeles CA Gunshot Los Angeles Police Department Firearm
351 340 Luis Molina Martinez 35 Male Hispanic/Latino April 21 2015 3400 Manitou Ave Los Angeles CA Gunshot Los Angeles Police Department Knife
398 384 Brendon Glenn 29 Male Black May 6 2015 52 Windward Ave Los Angeles CA Gunshot Los Angeles Police Department No
577 576 Jason Hendley 29 Male Black July 6 2015 13000 Gavina Ave Los Angeles CA Gunshot Los Angeles Police Department Knife
595 595 Neil White 38 Male White July 9 2015 800 S Sycamore Ave Los Angeles CA Gunshot Los Angeles Police Department Other
610 617 Jason Davis 41 Male White July 13 2015 671 Rose Ave Los Angeles CA Gunshot Los Angeles Police Department Other
716 718 Redel Jones 30 Female Black August 12 2015 Marlton Avenue and Santo Tomas Drive Los Angeles CA Gunshot Los Angeles Police Department Knife
763 769 Manuel Soriano 29 Male Hispanic/Latino August 27 2015 Van Nuys Blvd and Valerio St Los Angeles CA Gunshot Los Angeles Police Department Other
824 833 Florencio Chaidez 32 Male Hispanic/Latino September 15 2015 Parthenia St and Cedros Ave Los Angeles CA Gunshot Los Angeles Police Department Firearm
828 840 Carlos Wilhelm 39 Male Hispanic/Latino September 16 2015 4100 Willimet St Los Angeles CA Gunshot Los Angeles Police Department Firearm
866 874 Norma Guzman 37 Female Hispanic/Latino September 27 2015 2100 S San Pedro St Los Angeles CA Gunshot Los Angeles Police Department Knife
878 889 James Byrd 45 Male White October 3 2015 Sepulveda Blvd and Victory Blvd Los Angeles CA Gunshot Los Angeles Police Department No
921 937 Dion Ramirez 54 Male Black October 19 2015 400 W 111th St Los Angeles CA Gunshot Los Angeles County Sheriff's Department Vehicle
981 1000 Miguel Cano 34 Male Hispanic/Latino November 9 2015 Andasol Ave and Elkwood St Los Angeles CA Gunshot Los Angeles Police Department Unknown

8) What was the month with more police killings in 2015?


In [14]:
df['month'].value_counts()


Out[14]:
July         124
March        114
August       102
April        102
September     96
December      95
January       91
October       90
May           86
November      84
February      83
June          79
Name: month, dtype: int64

9) What was the day with more police killings in July?


In [15]:
df['July'] = df['month'] == 'July'
df['July'].value_counts()


Out[15]:
False    1022
True      124
Name: July, dtype: int64

In [16]:
july_count = df.groupby('month')['day'].value_counts()
pd.DataFrame(july_count)

#I tried to do df.groupby('July')['day'].value_counts() but it did not work.
#Here I am getting the results but I am not able to see July.


Out[16]:
day
month day
April 21 8
8 7
15 7
2 5
4 5
6 5
22 5
30 5
9 4
12 4
23 4
25 4
28 4
3 3
14 3
16 3
17 3
19 3
26 3
29 3
1 2
10 2
13 2
18 2
24 2
7 1
11 1
20 1
27 1
August 5 6
... ... ...
September 21 7
4 5
5 5
10 5
23 5
1 4
6 4
9 4
13 4
18 4
22 4
24 4
26 4
7 3
15 3
20 3
25 3
27 3
29 3
3 2
8 2
11 2
12 2
14 2
16 2
17 2
28 2
2 1
19 1
30 1

342 rows × 1 columns

10) How are these killings distributed by race?


In [17]:
df['raceethnicity'].value_counts()
#this results do not align with those in the Guardian's website. ???


Out[17]:
White                     582
Black                     305
Hispanic/Latino           195
Asian/Pacific Islander     24
Unknown                    22
Native American            13
Arab-American               4
Other                       1
Name: raceethnicity, dtype: int64

11) And by gender?


In [18]:
df['gender'].value_counts()


Out[18]:
Male              1092
Female              53
Non-conforming       1
Name: gender, dtype: int64

12) How many of the people killed where carrying a firearm?


In [19]:
df['armed'].value_counts()


Out[19]:
Firearm               554
No                    229
Knife                 154
Other                  62
Unknown                54
Non-lethal firearm     45
Vehicle                44
Disputed                4
Name: armed, dtype: int64

In [20]:
df.head(20)


Out[20]:
uid name age gender raceethnicity month day year streetaddress city state classification lawenforcementagency armed July
0 2 Matthew Ajibade 22 Male Black January 1 2015 1050 Carl Griffin Dr Savannah GA Death in custody Chatham County Sheriff's Office No False
1 4 Lewis Lembke 47 Male White January 2 2015 4505 SW Masters Loop Aloha OR Gunshot Washington County Sheriff's Office Firearm False
2 7 Tim Elliott 53 Male Asian/Pacific Islander January 2 2015 600 E Island Lake Dr Shelton WA Gunshot Mason County Sheriff's Office Firearm False
3 5 Michael Kocher Jr 19 Male White January 3 2015 2600 Kaumualii Hwy Kaumakani HI Struck by vehicle Kauai Police Department No False
4 6 John Quintero 23 Male Hispanic/Latino January 3 2015 500 North Oliver Ave Wichita KS Gunshot Wichita Police Department No False
5 8 Matthew Hoffman 32 Male White January 4 2015 630 Valencia St San Francisco CA Gunshot San Francisco Police Department Non-lethal firearm False
6 91 Kenneth Brown 18 Male White January 4 2015 NaN Guthrie OK Gunshot Oklahoma State Police Firearm False
7 9 Kenneth Buck 22 Male Hispanic/Latino January 5 2015 E Knox Rd and N Exeter St Chandler AZ Gunshot Chandler Police Department Firearm False
8 10 Michael Rodriguez 39 Male Hispanic/Latino January 5 2015 818 31st St Evans CO Gunshot Evans Police Department Other False
9 1010 Frank Smart 39 Male Black January 5 2015 950 Second Ave Pittsburgh PA Death in custody Allegheny County Bureau of Corrections No False
10 11 Patrick Wetter 25 Male White January 6 2015 800 Howard St Stockton CA Gunshot Stockton Police Department Knife False
11 12 Brian Pickett 26 Male Black January 6 2015 1618 E 123rd St Los Angeles CA Taser Los Angeles County Sheriff's Department No False
12 13 Autumn Steele 34 Female White January 6 2015 104 N Garfield Ave Burlington IA Gunshot Burlington Police Department No False
13 14 Brock Nichols 35 Male White January 6 2015 2388 E Kansas Hwy 4 Assaria KS Gunshot Saline County Sheriff's Office Firearm False
14 15 Leslie Sapp III 47 Male Black January 6 2015 Redlyn St Pittsburgh PA Gunshot US Marshals Service, Pennsylvania State Police... Non-lethal firearm False
15 16 Nicholas Brickman 30 Male White January 7 2015 SE 4th St and Scott Ave Des Moines IA Gunshot Des Moines Police Department Firearm False
16 17 Joseph Caffarello 31 Male White January 7 2015 6300 Scott St Rosemont IL Gunshot Rosemont Police Department Vehicle False
17 20 Andre Murphy Sr 42 Male Black January 7 2015 1223 Omaha Ave Norfolk NE Death in custody Norfolk Police Division No False
18 422 Hashim Abdul-Rasheed 41 Male Black January 7 2015 4600 International Gateway Columbus OH Gunshot Columbus Police Department Knife False
19 18 Ronald Sneed 32 Male Black January 7 2015 310 Yaupon St Freeport TX Gunshot Freeport Police Department Firearm False

13) Which was the law enforcement agency with more killings?


In [21]:
df['lawenforcementagency'].value_counts()


Out[21]:
Los Angeles Police Department                                                23
Los Angeles County Sheriff's Department                                      15
Houston Police Department                                                    11
Chicago Police Department                                                    10
New York Police Department                                                   10
Indianapolis Metropolitan Police Department                                   9
Las Vegas Metropolitan Police Department                                      9
San Francisco Police Department                                               8
Oklahoma City Police Department                                               8
Phoenix Police Department                                                     8
Miami-Dade Police Department                                                  7
Dallas Police Department                                                      7
San Diego Police Department                                                   7
Austin Police Department                                                      7
Riverside County Sheriff's Department                                         7
San Jose Police Department                                                    6
Jacksonville Sheriff's Office                                                 6
Pennsylvania State Police                                                     6
Bakersfield Police Department                                                 6
San Antonio Police Department                                                 5
Fresno Police Department                                                      5
Aurora Police Department                                                      5
Baltimore County Police Department                                            5
Washington County Sheriff's Office                                            5
Unknown                                                                       5
Harris County Sheriff's Office                                                5
Fort Worth Police Department                                                  5
Long Beach Police Department                                                  5
Oakland Police Department                                                     5
Mesa Police Department                                                        4
                                                                             ..
Conecuh County Sheriff's Office, Alabama Department of Public Safety          1
Orange County Sheriff's Department                                            1
Los Angeles County Sheriff‰Ûªs Department, Baldwin Park Police Department     1
Franklin Parish Sheriff's Office                                              1
Delano Police Department                                                      1
Contra Costa Sheriff's Office                                                 1
Elizabethtown Police Department                                               1
Vermont State Police, Drug Enforcement Administration                         1
Floyd County Sheriff's Office                                                 1
Farmersville Police Department                                                1
Dekalb County Sheriff's Department, Missouri State Highway Patrol             1
Nocona Police Department                                                      1
Fountain Police Department                                                    1
Seaside Police Department                                                     1
Haverhill Police Department                                                   1
St Tammany Parish Sheriff's Office                                            1
Alton Police Department                                                       1
Maricopa Police Department                                                    1
Kansas City Police Department, US Marshals                                    1
Metropolis Police Department                                                  1
Freeport Police Department                                                    1
Marana Police Department                                                      1
Las Vegas Police Department                                                   1
Winston Salem Police Department                                               1
San Bernardino County Sheriff's Office                                        1
Summit County Sheriff's Office                                                1
Tulalip Tribal Police Department, Snohomish County Sheriff's Office           1
Ca̱on City Police Department                                                 1
Grand Junction Police Department                                              1
Green County Sheriff's Department                                             1
Name: lawenforcementagency, dtype: int64

13) How many people were killed in custody?


In [22]:
df['classification'].value_counts()


Out[22]:
Gunshot              1019
Taser                  49
Death in custody       43
Struck by vehicle      34
Other                   1
Name: classification, dtype: int64

14) List the people killed who where male, Hispanic/Latino and armed with a knife?


In [23]:
male = df['gender'] == 'Male'
latino = df['raceethnicity'] == 'Hispanic/Latino'
knife = df['armed'] == 'Knife'
df[male&latino&knife]

#How can I count them now? It tells me it is not possible?


Out[23]:
uid name age gender raceethnicity month day year streetaddress city state classification lawenforcementagency armed July
40 42 Jose Ceja 36 Male Hispanic/Latino January 15 2015 2007 Sousa Ct Fairfield CA Gunshot Fairfield Police Department Knife False
54 53 Daniel Brumley 25 Male Hispanic/Latino January 17 2015 NE 36th St Fort Worth TX Gunshot Fort Worth Police Department Knife False
66 65 Jose Antonio Espinoza Ruiz 56 Male Hispanic/Latino January 23 2015 202 Avenue A Levelland TX Gunshot Levelland Police Department Knife False
72 72 David Garcia 33 Male Hispanic/Latino January 26 2015 1134 E St Wasco CA Gunshot Kern County Sheriff's Office Knife False
131 133 Daniel Mejia 37 Male Hispanic/Latino February 15 2015 200 S McNab Pkwy San Manuel AZ Gunshot Pinal County Sheriff's Office Knife False
163 161 Amilcar Perez-Lopez 21 Male Hispanic/Latino February 26 2015 Folsom St and 24th St San Francisco CA Gunshot San Francisco Police Department Knife False
267 264 Adrian Solis 35 Male Hispanic/Latino March 26 2015 1515 Bayview Ave Wilmington CA Gunshot Los Angeles Police Department Knife False
320 313 Angel Corona Jr 21 Male Hispanic/Latino April 10 2015 4740 Barham Ave Corning CA Gunshot Tehama County Sheriff's Department Knife False
339 330 Rodolfo Velazquez 47 Male Hispanic/Latino April 16 2015 West Lerdo Hwy and South Wall St Shafter CA Gunshot Shafter Police Department Knife False
351 340 Luis Molina Martinez 35 Male Hispanic/Latino April 21 2015 3400 Manitou Ave Los Angeles CA Gunshot Los Angeles Police Department Knife False
359 349 Carlos Ramirez 51 Male Hispanic/Latino April 22 2015 101 Naco Hwy Bisbee AZ Gunshot Bisbee Police Department Knife False
434 425 Alfredo Rials-Torres 54 Male Hispanic/Latino May 19 2015 4219 2nd Road N Arlington VA Gunshot Arlington Police Department Knife False
441 436 Elvin Diaz 24 Male Hispanic/Latino May 21 2015 10 Temple Ave Hackensack NJ Gunshot Hackensack Police Department Knife False
483 471 Edelmiro Hernandez 33 Male Hispanic/Latino June 3 2015 11799 Featherwood Dr Houston TX Gunshot Houston Police Department Knife False
495 491 Rene Garcia 30 Male Hispanic/Latino June 8 2015 La Palma Ave and Helena St Anaheim CA Gunshot Anaheim Police Department Knife False
507 505 Raymond Peralta-Lantigua 22 Male Hispanic/Latino June 11 2015 185Johnson Ave Hackensack NJ Gunshot Hackensack Police Department Knife False
529 526 Santos Laboy 45 Male Hispanic/Latino June 19 2015 Charles River Esplanade Boston MA Gunshot Massachusetts State Police Knife False
563 562 Cesar Juarez 27 Male Hispanic/Latino July 3 2015 700 Nogales St West Covina CA Gunshot West Covina Police Department Knife True
579 587 David Sarabia 27 Male Hispanic/Latino July 6 2015 Green Sands Ave and Augusta Ln Atwater CA Gunshot Atwater Police Department Knife True
698 695 Gustavo Ponce-Galon 42 Male Hispanic/Latino August 6 2015 159 Seneca Trail Elsmere KY Gunshot Elsmere Police Department Knife False
707 711 Edrian Rivera 22 Male Hispanic/Latino August 9 2015 San Antonio Ave and Packing Pl San Jose CA Gunshot San Jose Police Department Knife False
773 778 Roger Albrecht 43 Male Hispanic/Latino August 29 2015 6500 Spring Branch St San Antonio TX Gunshot San Antonio Police Department Knife False
810 817 Santino Burce 34 Male Hispanic/Latino September 10 2015 Valley Blvd and Juniper Ave Fontana CA Gunshot Fontana Police Department Knife False
875 887 Christian Pena 26 Male Hispanic/Latino October 2 2015 200 S Linden Ave Rialto CA Gunshot Rialto Police Department Knife False
887 902 Gary Boitano 19 Male Hispanic/Latino October 9 2015 6400 Cardinal Ln Columbia MD Gunshot Howard County Police Department Knife False
896 911 Robert Medellin 43 Male Hispanic/Latino October 11 2015 5200 W 40th St Odessa TX Gunshot Ector County Sheriff's Office Knife False
928 942 Miguel Galena 35 Male Hispanic/Latino October 21 2015 200 East First Street Calexico CA Gunshot US Customs and Border Protection Knife False
994 1013 Moises Nerio 42 Male Hispanic/Latino November 12 2015 1200 Ayala Dr Sunnyvale CA Gunshot Sunnyvale Bureau of Police Services Knife False
1024 1045 Henry Reyna 49 Male Hispanic/Latino November 23 2015 5000 Concord St Corpus Christi TX Gunshot Corpus Christi Police Department Knife False
1071 1098 Roy Carreon 49 Male Hispanic/Latino December 12 2015 500 Tia Juana St N San Bernardino CA Gunshot San Bernardino Police Department Knife False
1117 1142 Omar Ventura 23 Male Hispanic/Latino December 24 2015 200 N Larson St Porterville CA Gunshot Porterville Police Department Knife False
1132 1157 Fred Perez 55 Male Hispanic/Latino December 30 2015 E Belmont Ave and N Weber Ave Fresno CA Gunshot Fresno Police Department Knife False

In [24]:
df['gender'].value_counts()


Out[24]:
Male              1092
Female              53
Non-conforming       1
Name: gender, dtype: int64

In [25]:
#doesn't look right!
plt.style.use('ggplot')
df['age'].value_counts().hist()


Out[25]:
<matplotlib.axes._subplots.AxesSubplot at 0x10c41ef60>

In [26]:
#we had to create a new list since histograms need floats and we had strings (unknown)

age2 = []
for point in df['age']:
    if point != 'Unknown':
        age2.append(float(point))
    else:
        age2.append(0)

df['age_2'] = age2

df['age_2'].hist()

df['age'].sort_values()
        
#we still have unknown values plotted


Out[26]:
906          15
711          15
519          15
243          16
863          16
1002         16
154          16
739          17
855          17
510          17
172          17
862          17
92           17
74           17
63           17
432          17
594          17
299          17
482          18
918          18
587          18
944          18
900          18
969          18
469          18
403          18
1040         18
882          18
779          18
6            18
         ...   
56           67
977          68
419          68
36           68
75           68
593          68
1034         69
494          69
47           69
684          71
25           71
402          72
334          72
1133         74
1145         74
112          74
34           75
375          76
615          76
781          76
269          77
613          77
709          77
326          83
508          85
35           87
147     Unknown
1072    Unknown
1066    Unknown
88      Unknown
Name: age, dtype: object

In [27]:
no_unknowns = df.drop(df.index[[147, 1072, 1066, 88]])

no_unknowns['age'].sort_values()

age2 = []
for point in no_unknowns['age']:
    age2.append(float(point))

no_unknowns['age2'] = age2

no_unknowns['age2'].hist()


Out[27]:
<matplotlib.axes._subplots.AxesSubplot at 0x10c51f400>

In [28]:
df['state'].value_counts().hist()

df['state'].value_counts()


Out[28]:
CA    211
TX    110
FL     71
AZ     44
GA     39
OK     38
OH     37
CO     32
LA     28
NC     26
NY     25
PA     24
WA     23
IL     23
NJ     23
VA     23
MO     22
NM     21
TN     21
SC     21
IN     21
MI     20
NV     19
KY     19
AL     19
MD     17
OR     17
MN     13
WI     12
WV     12
MS     12
KS     11
UT     10
MA     10
NE      9
ID      8
DC      7
WY      6
AR      5
HI      5
AK      5
IA      5
DE      4
MT      4
CT      4
NH      3
ME      2
SD      2
RI      1
VT      1
ND      1
Name: state, dtype: int64

In [ ]:


In [ ]:


In [ ]: