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
Handling Missing Data in Python
00:00
5 left

Handling Missing Data in Python

MediumSQL · PostgreSQL

Problem

Can you explain how you handle missing values, duplicates, and data reshaping using Python libraries like Pandas and NumPy?

Translate this data-cleaning task into PostgreSQL using raw_metric_readings and metric_catalog. Keep missing metric values as NULL, retain only the latest duplicate reading, and produce the requested wide result.

Output

  1. One row per device and reading timestamp
  2. Columns: device_id, reading_time, temperature_c, humidity_pct, and power_w
  3. Include only timestamps with at least one recognized target metric, ordered by device_id and reading_time ascending

Schema

raw_metric_readings
ColumnTypeDescription
reading_idPKINTUnique identifier for the raw reading
device_idVARCHAR(20)Identifier of the AMD device
reading_timeTIMESTAMPTimestamp represented by the reading
metric_nameVARCHAR(40)Name of the recorded metric
metric_valueDECIMAL(10,2)Numeric metric value, which may be missing
ingested_atTIMESTAMPTime the row was ingested
metric_catalog
ColumnTypeDescription
metric_namePKVARCHAR(40)Recognized metric name
display_nameVARCHAR(80)Human-readable metric label
Tablesraw_metric_readingsmetric_catalog
Interviewer

Your question is Handling Missing Data in Python. Start with the requirements and the two tables 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.