Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Clean and Transform Disjoint Logs

HardSQL · PostgreSQL00:00
Practice interviewer
In session
5 left
00:00

Your question is Clean and Transform Disjoint Logs. Start with the requirements and the two tables on the right.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.

Problem

Using Pandas, how would you clean, merge, and transform a dataset containing disjointed user activity logs?

Translate this data-wrangling task into PostgreSQL using the users and activity_logs tables. Normalize user identifiers and event labels, exclude unusable events, remove duplicate normalized records, and summarize activity by user and date.

Output

  1. One row per user and activity date, including users without valid activity.
  2. Return user_id, activity_date, total_events, active_minutes, and primary_activity.
  3. Sort by user_id, then activity_date ascending, with missing dates first.

Schema

users
ColumnTypeDescription
user_idPKINTCanonical user identifier
full_nameVARCHAR(100)User's full name
emailVARCHAR(255)Canonical user email address
activity_logs
ColumnTypeDescription
log_idPKINTActivity log identifier
user_emailVARCHAR(255)Raw user email from the activity source
event_timestampTIMESTAMPTimestamp when the activity occurred
event_typeVARCHAR(50)Raw activity label
duration_minutesINTDuration associated with the activity
Tablesusersactivity_logs
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results