关于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)
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)
相关文章推荐
- Java中String、StringBuffer、StringBuilder简述及区别
- c++第5次实验
- iOS9开发最简单的设置导航栏透明UINavigationBar透明
- JavaScript 阻止默认时间和冒泡时间
- 单选框功能及同一页面显示
- HDU 4009 Transfer water 最小树形图
- node如何让一个端口同时支持https与http
- <<C++ Primer中文版(第五版)>>练习
- 在Android Studio中进行单元测试和UI测试
- 【POJ】2262-哥德巴赫猜想
- Python Lib Queue.py
- Google Chrome浏览器 控制台全解析
- uvalive3610
- CSharpGL(23)用ComputeShader实现一个简单的ParticleSimulator
- linux中的fork函数的基本用法
- 3-23高项作业
- STM32F4学习笔记6——USART Part1
- 图的深度和广度遍历(邻接矩阵)
- Android开发笔记之Canvas的相关方法
- PHP实现进程锁的方法以及详解