LoslegenKostenlos loslegen

Using pandas functions effectively

You are creating a Python application that will calculate summary statistics based on user-selected variables. The complete dataset is quite large. For now, you are setting up your code using part of the dataset, preloaded as adult. As you create a reusable process, make sure you are thinking through the most efficient way to setup the GroupBy object.

Diese Übung ist Teil des Kurses

Working with Categorical Data in Python

Kurs anzeigen

Anleitung zur Übung

  • Create a list of the names for two user-selected variables: "Education" and "Above/Below 50k".
  • Create a GroupBy object, gb, using the user_list as the grouping variables.
  • Calculate the mean of "Hours/Week" across each group using the most efficient approach covered in the video.

Interaktive Übung

Vervollständige den Beispielcode, um diese Übung erfolgreich abzuschließen.

# Create a list of user-selected variables
user_list = ____

# Create a GroupBy object using this list
gb = ____

# Find the mean for the variable "Hours/Week" for each group - Be efficient!
print(____)
Code bearbeiten und ausführen