Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
Clean and Transform Unstructured Datasets
00:00
5 left

Clean and Transform Unstructured Datasets

MediumSQL · PostgreSQL

Problem

Tell me about how you would clean and transform a set of unstructured datasets using SQL or Pandas within a strict time limit.

Use the provided raw trade reports and instrument reference data. Return only valid, completed trades after normalizing dates, symbols, sides, quantities, and prices. Rows with an invalid or NULL date, blank or unknown symbol, non-positive quantity, negative price, or unsupported status must be ignored.

Output

  1. One row per retained trade with report_id, trade_date, symbol, instrument_name, side, quantity, and price
  2. Sort by trade_date ascending, then report_id ascending

Schema

raw_trade_reports
ColumnTypeDescription
report_idPKINTEGERUnique raw trade report identifier
reported_at_textVARCHAR(40)Trade date in an inconsistent text format
symbol_textVARCHAR(40)Raw instrument symbol
quantity_textVARCHAR(40)Raw quantity with possible punctuation or units
price_textVARCHAR(40)Raw price with possible currency text
side_textVARCHAR(20)Raw buy or sell designation
status_textVARCHAR(20)Raw execution status
instrument_reference
ColumnTypeDescription
symbolPKVARCHAR(20)Canonical instrument symbol
instrument_nameVARCHAR(80)Canonical instrument name
Tablesraw_trade_reportsinstrument_reference
Interviewer

Your question is Clean and Transform Unstructured Datasets. 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
You need to log in / sign up to run or submit.Ln 1
Run your query to see results here.