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

Tallying violations by district

The state of Rhode Island is broken into six police districts, also known as zones. How do the zones compare in terms of what violations are caught by police?

In this exercise, you'll create a frequency table to determine how many violations of each type took place in each of the six zones. Then, you'll filter the table to focus on the "K" zones, which you'll examine further in the next exercise.

Bu egzersiz

Analyzing Police Activity with pandas

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

Egzersiz talimatları

  • Create a frequency table from the ri DataFrame's district and violation columns using the pd.crosstab() function.
  • Save the frequency table as a new object, all_zones.
  • Select rows 'Zone K1' through 'Zone K3' from all_zones using the .loc[] accessor.
  • Save the smaller table as a new object, k_zones.

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

# Create a frequency table of districts and violations
print(____)

# Save the frequency table as 'all_zones'
all_zones = ____

# Select rows 'Zone K1' through 'Zone K3'
print(all_zones.____)

# Save the smaller table as 'k_zones'
k_zones = all_zones.____
Kodu Düzenle ve Çalıştır