Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Python Data Cleaning Function

EasyPython00:00
Practice interviewer
In session
5 left
00:00

Your question is Python Data Cleaning Function. Start with the requirements on the right.

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.

Problem

Write a Python function that processes a given dataset and returns the cleaned version.

For grading, treat dataset as a list of dictionaries with string keys. Return a new list where string values are stripped of leading and trailing whitespace, and fields with None or empty string values are removed. Preserve record order and do not mutate the input.

Constraints

  • 0 <= len(dataset) <= 1000
  • Each dataset element is a dictionary with string keys
  • Values are strings, integers, floats, booleans, or None
  • Record order must be preserved
  • The input dataset must not be mutated

Function Signature

def clean_dataset(dataset):
Your solutionPython 3
You need to log in / sign up to run or submit.
Run your code to see test output