How do we calculate category revenue within each individual retail store location?
Grouping simultaneously across store_id and product_category to produce fine-grained category revenue sums.
Store merchandising optimization, inventory allocation, and local demand forecasting.
from pyspark.sql.functions import col, sum
df.groupBy("store_id", "product_category").agg(
sum(col("revenue")).alias("category_revenue")
).show()Practice typing production-grade PySpark code for Multi-Dimensional Group Aggregation.