How can we compare a customer's current order value against their very first order value?
first('amount') over an unbounded window extracts the earliest recorded transaction value for comparative analysis.
Customer lifetime value progression, initial vs current pricing comparisons, and onboarding performance.
w = Window.partitionBy("customer_id").orderBy("order_date").rowsBetween(Window.unboundedPreceding, Window.unboundedFollowing)
df_baseline = df.withColumn("initial_order_amount", first("amount").over(w))Practice typing production-grade PySpark code for First and Last Values with Frame Boundaries.