python python-get-revenue-for-order-id-mapreduce.py

Posted

tags:

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

path = "/Users/itversity/Research/data/retail_db/order_items/part-00000"
orderItems = open(path).read().splitlines()

def getOrderRevenueMR(orderItems, orderId):
    orderItemsFiltered = filter(lambda o: int(o.split(",")[1]) == orderId, orderItems)
    orderItemsMap = map(lambda o: float(o.split(",")[4]), orderItemsFiltered)
    orderRevenue = reduce(lambda total, revenue: total + revenue, orderItemsMap)
    return orderRevenue

print(getOrderRevenueMR(orderItems, 2))

以上是关于python python-get-revenue-for-order-id-mapreduce.py的主要内容,如果未能解决你的问题,请参考以下文章

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

Python开发

Python,python,python

Python 介绍

Python学习之认识python

python初识