Write a Python script to handle missing data in a large dataset.
Implement handle_missing_data(records, numeric_fields, categorical_fields). Each record is a dictionary; a missing value is represented by None or an absent key. Return new records, replacing numeric missing values with their field mean and categorical missing values with their most frequent value. Break categorical frequency ties by choosing the lexicographically smallest value. Use 0.0 for an entirely missing numeric field and an empty string for an entirely missing categorical field. Do not mutate the input records.
def handle_missing_data(records, numeric_fields, categorical_fields):