Skip to interview prep
Apexed

6. Average rating pivot table

MediumPandas & NumPy

Rows have product, month and rating. Return a dict mapping each product to a dict of month → average rating (rounded to 1 decimal). Include only months that have ratings for that product.

Input rows arrive as a list of dictionaries; build a DataFrame with pd.DataFrame(rows).

Example 1

Input: …
Output: {'app': {'jan': 4.5, 'feb': 3.0}}

Constraints

  • Ratings are 1–5

Tab indents · Ctrl/⌘ + Enter runs · Esc then Tab leaves the editor

Run checks these cases; the expected output comes from the reference solution. Submit judges all 3 hidden and sample tests.

Code runs only in your browser in an isolated sandbox. Progress and submissions are saved on this device.

Average rating pivot table — coding interview practice — Apexed