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

Using .groupby() after reordering

It is now time to run some analyses on the adoptable dogs dataset that is focused on the "size" of the dog. You have already developed some code to reorder the categories. In this exercise, you will develop two similar .groupby() statements to help better understand the effect of "size" on other variables. dogs has been preloaded for you.

Bu egzersiz

Working with Categorical Data in Python

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

Egzersiz talimatları

  • Print out the frequency table of "sex" for each category of the "size" column.
  • Print out the frequency table of "keep_in" for each category of the "size" column.

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

# Previous code
dogs["size"].cat.reorder_categories(
  new_categories=["small", "medium", "large"],
  ordered=True,
  inplace=True
)

# How many Male/Female dogs are available of each size?
print(dogs.____(____)[____].value_counts())

# Do larger dogs need more room to roam?
print(dogs.____(____)[____].value_counts())
Kodu Düzenle ve Çalıştır