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
ExperiencesCoaching
New
Practice
Mock InterviewsTimed interview simulations with feedbackSuccess 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
Get started
Transform and Filter Data
00:00
5 left

Transform and Filter Data

MediumPython

Problem

In an Informatica Cloud Data Integration interface, users need to preview records after applying configurable filters and field transformations. Implement transform_records to filter an array of record objects and return transformed copies without mutating the input.

Formal Specification

The function receives records, a list of dictionaries, and criteria, a dictionary containing any of these optional keys:

  1. allowed_statuses: list of accepted status strings. A record passes when its status is included.
  2. min_score: numeric lower bound, inclusive. Records without a numeric score fail this filter.
  3. required_tags: list of tags. A record must contain every required tag in its tags array.
  4. name_contains: case-insensitive substring that must occur in the record's name.
  5. include_fields: fields to retain in each output record. If omitted, retain all fields.
  6. rename: mapping from source field names to output field names. Apply this only to retained fields.

All specified filters must pass. Preserve record order. Missing fields fail only the filter that requires them. Return a new list and do not mutate any input dictionary.

Constraints

  • 0 <= len(records) <= 10^4
  • Each record contains string keys and JSON-compatible values
  • required_tags and include_fields contain unique strings
  • Rename targets are unique and do not collide with retained, unrenamed fields
  • All specified filters must pass

Function Signature

def transform_records(records, criteria):
Interviewer

Your question is Transform and Filter Data. 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.
Code
Sign up free to run your codeLog inLn 2
Run your code to see test output here.