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

Reshaping the arrest rate data

In this exercise, you'll start by reshaping the arrest_rate Series into a DataFrame. This is a useful step when working with any multi-indexed Series, since it enables you to access the full range of DataFrame methods.

Then, you'll create the exact same DataFrame using a pivot table. This is a great example of how pandas often gives you more than one way to reach the same result!

Bu egzersiz

Analyzing Police Activity with pandas

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

Egzersiz talimatları

  • Unstack the arrest_rate Series to reshape it into a DataFrame.
  • Create the exact same DataFrame using a pivot table! Each of the three .pivot_table() parameters should be specified as one of the ri_weather columns.

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

# Unstack the 'arrest_rate' Series into a DataFrame
print(arrest_rate.____)

# Create the same DataFrame using a pivot table
print(ri_weather.pivot_table(index='____', columns='____', values='is_arrested'))
Kodu Düzenle ve Çalıştır