python core-spark-aggregating-by-key.py

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python core-spark-aggregating-by-key.py相关的知识,希望对你有一定的参考价值。

#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

以上是关于python core-spark-aggregating-by-key.py的主要内容,如果未能解决你的问题,请参考以下文章

Python代写,Python作业代写,代写Python,代做Python

Python开发

Python,python,python

Python 介绍

Python学习之认识python

python初识