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
Parse, Clean, Aggregate Crypto Logs
00:00
5 left

Parse, Clean, Aggregate Crypto Logs

MediumPython

Problem

Write a Python script to parse, clean, and aggregate a mock stream of cryptocurrency transaction logs.

Each log is a pipe-delimited string with the format timestamp|transaction_id|asset|side|amount|price|status. Implement aggregate_transactions(logs) to ignore malformed records, normalize asset and status casing, accept only positive numeric amounts and prices with buy or sell sides, include only completed transactions, and ignore duplicate valid transaction IDs. Return a dictionary keyed by uppercase asset, with volume and notional totals rounded to 8 decimal places. Output keys must be inserted in sorted asset order.

Constraints

  • 1 <= len(logs) <= 5000
  • Each log is a string with at most 7 pipe-delimited fields
  • Transaction IDs are arbitrary nonempty strings
  • Amounts and prices must be finite positive decimal values
  • Only records with status completed and side buy or sell are aggregated
  • Duplicate valid transaction IDs are ignored after their first occurrence

Function Signature

def aggregate_transactions(logs):
Interviewer

Your question is Parse, Clean, Aggregate Crypto Logs. 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.