How can we sanitize text strings, standardize dates, and impute missing monetary values with median defaults?
Combining trim(), to_timestamp(), and fillna() cleans all fields in preparation for business transformations.
Data preparation and cleansing in enterprise Silver ETL layers.
df_clean = df_parsed.withColumn("event_id", trim(col("event_id"))).withColumn("event_timestamp", to_timestamp(col("timestamp"))).fillna({"amount": 0.0, "user_id": "UNKNOWN"})Practice typing production-grade PySpark code for Capstone Part 2: Automated Null Imputation and Cleaning.