Get startedGet started for free

Comparing speeding outcomes by gender

When a driver is pulled over for speeding, many people believe that gender has an impact on whether the driver will receive a ticket or a warning. Can you find evidence of this in the dataset?

First, you'll create two DataFrames of drivers who were stopped for speeding: one containing females and the other containing males.

Then, for each gender, you'll use the stop_outcome column to calculate what percentage of stops resulted in a "Citation" (meaning a ticket) versus a "Warning".

This exercise is part of the course

Analyzing Police Activity with pandas

View Course

Exercise instructions

  • Create a DataFrame, female_and_speeding, that only includes female drivers who were stopped for speeding.
  • Create a DataFrame, male_and_speeding, that only includes male drivers who were stopped for speeding.
  • Count the stop outcomes for the female drivers and express them as proportions.
  • Count the stop outcomes for the male drivers and express them as proportions.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Create a DataFrame of female drivers stopped for speeding
female_and_speeding = ri[____]

# Create a DataFrame of male drivers stopped for speeding
male_and_speeding = ri[____]

# Compute the stop outcomes for female drivers (as proportions)
print(female_and_speeding.____)

# Compute the stop outcomes for male drivers (as proportions)
print(male_and_speeding.____)
Edit and Run Code