Analyzing Police Activity with pandas
Kevin Markham
Founder, Data School
female = ri[ri.driver_gender == 'F']
female.shape
(23774, 13)
female_and_arrested = ri[(ri.driver_gender == 'F') &
(ri.is_arrested == True)]
&
) represents the and
operatorfemale_and_arrested.shape
(669, 13)
female_or_arrested = ri[(ri.driver_gender == 'F') |
(ri.is_arrested == True)]
|
) represents the or
operatorfemale_or_arrested.shape
(26183, 13)
Ampersand (&
): only include rows that satisfy both conditions
Pipe (|
): include rows that satisfy either condition
Each condition must be surrounded by parentheses
Conditions can check for equality (==
), inequality (!=
), etc.
Can use more than two conditions
Analyze the relationship between gender and stop outcome
Not going to draw any conclusions about causation
Analyzing Police Activity with pandas