Skip to content
C

Problem 3: Create a Pivot Table

Easypython

Problem Description

Write a Python program that creates a pivot table showing average sales amount by region (rows) and month (columns).

Input

A DataFrame with "region", "month", and "amount" columns.

Output

A pivot table summarizing average amount by region and month.

Constraints

  • At least 2 regions and 2 months.

Example Input

text
{"region":["North","North","South","South"], "month":["Jan","Feb","Jan","Feb"], "amount":[100,120,150,140]}

Example Output

text
(A pivot table with regions as rows, months as columns, showing average amounts)

Concepts Covered

pivot_table(), aggfunc="mean".

Input (stdin)

Output

Run your code to see output here...