DataDriven
LearnPracticeInterviewDiscussDaily

A hard Python interview practice problem on DataDriven. Write and execute real python code with instant grading.

Domain
Python
Difficulty
hard
Seniority
L5

Problem

Given a list of record dicts and a list of operations, apply each operation in order to every record and return the transformed records. Each op is a dict with key 'op' (the operation) and key 'path' (dot-separated for nested fields, e.g. 'addr.country'). Supported ops: 'rename' (also carries 'new_name'), 'add' (also carries 'default' as the value to insert), 'remove' (no extra fields), 'cast' (also carries 'target_type' in 'int' / 'float' / 'str'). For 'add' on a nested path, create missing intermediate dicts. 'rename' / 'remove' / 'cast' on a missing path are no-ops.

Summary

Old schema in, new schema out.

Practice This Problem

Solve this Python problem with real code execution. DataDriven runs your Python code in a real environment and grades it automatically.

Related

  • All Practice Problems
  • Mock Interview Mode
  • Python Interview Questions
  • Data Engineering Interview Prep Guide
  • Daily Challenge
  • Data Engineering Lessons