Pivot daily users and revenue by platform
IntuitData Scientist · Technical ScreenLast updated
This question evaluates data manipulation and aggregation skills, specifically computing distinct user counts and revenue aggregates and reshaping results by platform; it is in the Data Manipulation (SQL/Python) domain and assesses practical application rather than purely conceptual understanding.
You are given transaction-level data and need daily aggregates by platform.
Input (Pandas DataFrame)
df with columns:
file_date(DATE or string parseable to date) — the activity dateid(INT/STRING) — user idsku(STRING) — product identifierprice(NUMERIC) — revenue for the row (assume already in a single currency)channel(STRING)customer_segment(STRING)platform(STRING) — e.g.,'web','mobile'
Example rows:
01-01-2024, 123, A, 57, seo, alpha, web01-07-2024, 943, C, 100, tv, alpha, mobile
Task
Compute, for each file_date and platform:
total_users= number of distinctidtotal_revenue= sum ofprice
Then reshape the result into a pivoted/wide daily report with one row per day and separate columns per platform:
file_dateweb_total_users,web_total_revenuemobile_total_users,mobile_total_revenue
(If additional platforms exist, include them similarly.)
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.