DataDriven
LearnPracticeInterviewDiscussDailyJobs

The Pandas Pivot

A medium Python interview practice problem on DataDriven. Write and execute real python code with instant grading.

Domain
Python
Difficulty
medium
Seniority
L4

Problem

Given a list of event dicts (each with 'user_id', 'event_type', 'amount'), pivot so each user becomes one dict containing one column per distinct event_type (whose value is the sum of that user's amounts for that event_type) plus a final 'user_id' column. Only include event_type columns the user actually has (a sparse pivot; missing event_types are simply absent). Within each user's dict, place the event_type columns first, ordered by descending summed amount, and put 'user_id' last. Return the list of per-user dicts sorted by user_id ascending.

Summary

Rows become columns. Columns become power.

Practice This Problem

Solve this Python problem with real code execution. DataDriven runs your Python code in a real environment and grades it automatically.

Related

  • All Practice Problems
  • Mock Interview Mode
  • Python Interview Questions
  • Data Engineering Interview Prep Guide
  • Daily Challenge
  • Data Engineering Lessons