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
Normalize Uber Eats Order JSON
00:00
5 left

Normalize Uber Eats Order JSON

HardPython

Problem

Write a script to clean, transform, and normalize nested JSON payload data from a simulated Uber Eats order event stream.

Implement normalize_order_events(events). Trim string identifiers, lowercase statuses, uppercase currencies, convert valid monetary values to integer cents using half-up rounding, and aggregate valid duplicate items by ID. Skip events without an order ID and invalid items. Return one normalized object per valid order with missing scalar values represented by null.

Input is a list of JSON objects. Each output object contains event_id, order_id, status, customer_id, total_cents, currency, and items; each item contains item_id, name, quantity, and unit_price_cents.

Constraints

  • 1 <= len(events) <= 10^4
  • Each event is a JSON-compatible dictionary containing an optional payload object
  • Each valid order has a non-empty string-convertible id
  • Item quantities must be positive integers after conversion
  • Monetary values are decimal-compatible strings or numbers
  • Duplicate items are identified by normalized item ID

Function Signature

def normalize_order_events(events):
Interviewer

Your question is Normalize Uber Eats Order JSON. Start with the requirements 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.
CodePython 3
Sign up free to run your codeLog inLn 2
Run your code to see test output here.