PracHub
QuestionsPremiumLearningGuidesInterview PrepNEWCoaches

Quick Overview

This question evaluates a candidate's skill in group-wise aggregation and data transformation on JSON-like event streams, specifically computing per-user average metrics and producing ranked results.

  • Medium
  • Upstart
  • Data Manipulation (SQL/Python)
  • Data Scientist

Calculate Average Event Value by User ID

Company: Upstart

Role: Data Scientist

Category: Data Manipulation (SQL/Python)

Difficulty: Medium

Interview Round: Technical Screen

events +----+---------+------------+-------+---------------------+ | id | user_id | event_type | value | timestamp | +----+---------+------------+-------+---------------------+ | 1 | 42 | click | 3.5 | 2024-03-10 10:00:00 | | 2 | 17 | view | 1.0 | 2024-03-10 10:01:05 | | 3 | 42 | purchase | 7.0 | 2024-03-10 10:02:30 | | 4 | 99 | click | 2.3 | 2024-03-10 10:04:11 | | 5 | 17 | purchase | 4.7 | 2024-03-10 10:05:45 | +----+---------+------------+-------+---------------------+ ##### Scenario You receive an API response that is a Python list of JSON objects, each describing a user event coming from a mobile-app funnel. ##### Question Write Python code that, given a list like events = [{"id":1,"user_id":42,"event_type":"click","value":3.5,"timestamp":"2024-03-10 10:00:00"}, ...], produces a dictionary mapping each user_id to the average value of their events. Return the result sorted by descending average value. ##### Hints Use defaultdict / pandas groupby; iterate only once if possible.

Quick Answer: This question evaluates a candidate's skill in group-wise aggregation and data transformation on JSON-like event streams, specifically computing per-user average metrics and producing ranked results.

Last updated: Mar 29, 2026

Loading coding console...

PracHub

Master your tech interviews with 7,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.

Related Coding Questions

  • Write monthly touches and last-touch SQL - Upstart (Medium)
  • Manipulate data in R with dplyr joins and windows - Upstart (Medium)
  • Solve SQL CTR and Python analytics tasks - Upstart (Medium)
  • Calculate User Revenue and Session Duration in Python - Upstart (Medium)