Pandas & Data Analysis·Practice drills 9

Drill 22: Inputs and outputs — GroupBy

Identify the inputs and outputs of the example.

Beginner 5 min read Lesson 226 of 300 Challenge included
What you will be able to do
  • Identify the inputs and outputs of the example.

Practice task

Identify the inputs and outputs of the example.

groupby.pyPython
import pandas as pd

df = pd.DataFrame({
    'course': ['HTML', 'CSS', 'CSS', 'SQL'],
    'minutes': [12, 18, 22, 9],
})

summary = df.groupby('course').agg(
    lessons=('minutes', 'size'),
    total=('minutes', 'sum'),
    average=('minutes', 'mean'),
).reset_index().sort_values('total', ascending=False)

print(summary)
Your turn

Write your answer

Easy

Identify the inputs and outputs of the example.

TEXT · starter
Your answer…
Study tools

Make it yours.

Keep a private note for this lesson, then turn the key ideas into flashcards you can revisit.

Sign in to save notes and flashcards.Both are private to your account and stay with your progress.
Sign in
Finished reading?

Lock in what you just learned.

Mark this lesson complete to save your place and move one step closer to the certificate.

Lesson 226 of 300 · 0% of course