How do we calculate total sales revenue by geographic region using agg() and sum()?
groupBy('region').agg(sum('sales')) groups by territory and computes the total monetary sales.
Regional performance leaderboards, sales compensation tracking, and regional quota monitoring.
from pyspark.sql.functions import col, sum
df.groupBy("region").agg(sum(col("sales")).alias("total_sales")).show()Practice typing production-grade PySpark code for Segment Totals with sum().