Pandasdrill

Level 3: Aggregating Exercise 25 of 45 Pro

Counts with crosstab

A pandas exercise from Pandasdrill. Solve it with a Python editor in your browser running real pandas, and it is checked the moment you submit.

The task

Count the orders for each region (rows) and product (columns) with `pd.crosstab`.

What this exercise teaches

crosstab counts how often each pair of values appears. Missing pairs show 0 automatically, which makes it a quick way to build a frequency table.

A hint if you get stuck

The first argument of crosstab becomes the rows and the second becomes the columns.

This exercise is part of Pro

Pro unlocks all 45 exercises, with worked solutions and progress saved to your account. The free exercises work without an account.

You create a free account first, so Pro is attached to it.

Monthly is charged today and then every month until you cancel, in one click from your account page. Lifetime is one payment with no renewals. Full refund within 14 days of paying.

Start with the free exercises

More exercises in Aggregating