A data team at Acme Analytics stores raw dataset rows as Python dictionaries. Write a function to clean and preprocess these records by normalizing text fields, replacing missing values, and removing duplicate rows.
Given a list of records, where each record is a dictionary with string keys and values that may be strings, numbers, or None, return a new list of cleaned records.
A record should be cleaned using these rules:
"UNKNOWN".None values with "UNKNOWN".records, a list of dictionaries.Example 1
Input: records = [{"name": " Alice ", "city": " New York ", "age": 30}, {"name": "alice", "city": "new york", "age": 30}]
Output: [{"name": "alice", "city": "new york", "age": 30}]
Explanation: After trimming and lowercasing, both records become identical, so only the first is kept.
Example 2
Input: records = [{"name": " ", "city": null}, {"name": "Bob", "city": " Seattle "}]
Output: [{"name": "unknown", "city": "unknown"}, {"name": "bob", "city": "seattle"}]
Explanation: Blank strings and None are replaced, and strings are normalized.
1 <= len(records) <= 10^41 to 20 keys200