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

今天是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)

你可能感兴趣的:(关于spark中的"pyspark.resultiterable.ResultIterable" to a list)