您的位置:首页 > 其它

关于spark中的"pyspark.resultiterable.ResultIterable" to a list

2016-05-10 23:35 453 查看
今天是5月10号。接到这个project已经一个星期了。今天终于把代码调通顺了。在这次调代码的过程中,遇到了一个问题卡了两天。

Code:def nearestNeighbors(item_id,items_and_sims,n):

'''

Sort the predictions list by similarity and select the top-N neighbors

'''

items_and_sims.sort(key=lambda x: x[1][0],reverse=True)

return item_id, items_and_sims[:n]

在我运行完这段代码之后,报出了一个错误。

问题是:

”ResultIterable“ doesn't have the attribute “sort”

最终的解决方法:

list(items_and_sims).sort(key=lambda x: x[1][0],reverse=True)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: