Dataford
Interview QuestionsInterview GuidesExperiencesCoaching
New
Pricing
Get started
Dataford
Popular roles
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Browse
Browse All RolesEvery role hub, from analyst to MLBrowse All CompaniesCompany-specific interview loopsAll Interview GuidesThe full guide library
Top questions by role
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Top questions by skill
SQLPythonStatisticsMachine LearningA/B TestingSystem DesignGenerative AIProduct SenseMetricsBehavioral
Browse all questions →Try a mock interview
Experiences
Practice
Mock InterviewsTimed interview simulations with feedbackCoaching1:1 coaching with people at your target companiesSuccess PathYour 6-week structured planModulesCurated lessons by topicWebinarsTalks from ex-Big Tech data leadsPlaygroundA free-form scratch editor
Learn
BlogInterview strategy and career adviceTech Job Market ReportHiring trends across data and AI rolesFor UniversitiesDataford for career centersAbout DatafordWho we are and how we build
Pricing
Build my plan
Clean Messy Data With Pandas or Tidyverse
00:00
5 left

Clean Messy Data With Pandas or Tidyverse

MediumSQL · PostgreSQL

Problem

How do you clean and manipulate messy, real-world data in Python or R using Pandas, NumPy, or tidyverse for Amplify?

For this SQL version, apply equivalent cleaning logic to the provided Amplify event data. Exclude unusable records and summarize the remaining events by normalized channel.

Output

  1. One row per cleaned channel, with cleaned_channel, valid_event_count, and total_duration_seconds.
  2. Exclude rows with blank user IDs, missing durations, or negative durations.
  3. Order by total duration descending, then cleaned channel ascending.

Schema

amplify_events
ColumnTypeDescription
event_idPKINTUnique event identifier
user_idVARCHAR(50)Identifier of the user associated with the event
channelVARCHAR(50)Source channel recorded for the event
duration_secondsINTEvent duration in seconds
Tablesamplify_events
Interviewer

Your question is Clean Messy Data With Pandas or Tidyverse. Start with the requirements and the one table in the Question tab.

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.
CodePostgreSQL
Sign up free to run your codeLog inLn 1
Run your query to see results here.