How can we compute customer transaction risk scores using multi-condition when/otherwise business logic?
Evaluating amount thresholds, user tier, and region simultaneously assigns risk categories (HIGH, MEDIUM, LOW).
Automated fraud scoring and compliance risk classification in financial engineering.
df_scored = df_enriched.withColumn("risk_level", when((col("amount") > 10000) & (col("tier") == "BASIC"), "HIGH").when(col("amount") > 5000, "MEDIUM").otherwise("LOW"))Practice typing production-grade PySpark code for Capstone Part 5: Multi-Tier Categorization & Risk Scoring.