MulaiMulai sekarang secara gratis

Setting up a .groupby() statement

The gender wage gap is a hot-topic item in the United States and across the world. Using the adult census income dataset, loaded as adult, you want to check if some of the recently published data lines up with this income survey.

Latihan ini adalah bagian dari kursus

Working with Categorical Data in Python

Lihat Kursus

Petunjuk latihan

  • Split the adult dataset across the "Sex" and "Above/Below 50k" columns, saving this object as gb.
  • Print out the number of observations found in each group.
  • Using gb, find the average of each numerical column.

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

# Group the adult dataset by "Sex" and "Above/Below 50k"
gb = adult.____

# Print out how many rows are in each created group
print(____)

# Print out the mean of each group for all columns
print(____)
Edit dan Jalankan Kode