BaşlayınÜcretsiz Başlayın

Comparing frisk rates by gender

In this exercise, you'll compare the rates at which female and male drivers are frisked during a search. Are males frisked more often than females, perhaps because police officers consider them to be higher risk?

Before doing any calculations, it's important to filter the DataFrame to only include the relevant subset of data, namely stops in which a search was conducted.

Bu egzersiz

Analyzing Police Activity with pandas

kursunun bir parçasıdır
Kursu Görüntüle

Egzersiz talimatları

  • Create a DataFrame, searched, that only contains rows in which search_conducted is True.
  • Take the mean of the frisk column to find out what percentage of searches included a frisk.
  • Calculate the frisk rate for each gender using a .groupby().

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

# Create a DataFrame of stops in which a search was conducted
searched = ri[ri.____ == ____]

# Calculate the overall frisk rate by taking the mean of 'frisk'
print(searched.____)

# Calculate the frisk rate for each gender
print(searched.____)
Kodu Düzenle ve Çalıştır