#Check out our lab for practice: https://labs.itversity.com
#Computing Daily revenue and count per product id using aggregateByKey
dailyRevenueAndCountPerProductId = ordersJoinMap.\
aggregateByKey((0.0, 0),
lambda inter, revenue: (inter[0] + revenue, inter[1] + 1),
lambda final, inter: (final[0] + inter[0], final[1] + inter[1])
)
for i in dailyRevenuePerProductId.take(10): print(i)
#Raise any issues on https://discuss.itversity.com - make sure to categorize properly