pyhton3解决"tuple parameter unpacking is not supported"问题
准备将键值对中的键与值对调,结果第10行出了bug,显示"tuple parameter unpacking is not supported"
解决方法:将map(lambda(word,count) : (count,word)) 改为 map(lambda word_count : (word_count[1],word_count[0]))
原因:在python3中,类似
lambda (x, y): x + y 这种形式,已经被
lambda x_y: x_y[0] + x_y[1] 所取代,即使用 x_y 的形式代替 (x, y) ,即 x = x_y[0] y=x_y[1]
datas = ["hadoop spark", "spark hive spark sql", "spark hadoop sql spark"]
rdd1 = sc.parallelize(datas)
word_count_rdd = rdd1.flatMap(lambda line: line.split(" "))\
.map(lambda word: (word, 1))\
.reduceByKey(lambda a, b: a+b)
sorted_rdd = word_count_rdd\
.map(lambda(word,count ) :(count,word))\
.sortByKey(ascending=False)
pyhton3解决"tuple parameter unpacking is not supported"问题的更多相关文章
- 解决 cmake_symlink_library: System Error: Operation not supported
在编译uchardet时遇到这个错误: cmake_symlink_library: System Error: Operation not supported 创建链接不成功,要确认当前帐户下是否有 ...
- 用临时用户数据目录启动Chrome,关闭安全检查等(解决Cross origin requests are only supported for HTTP?)
Cross origin requests are only supported for HTTP? 参考:https://www.zhihu.com/question/20948649 批处理: s ...
- 解决:ElasticsearchException[X-Pack is not supported and Machine Learning is not available for
解决:在config/elasticsearch.yml添加一条配置: xpack.ml.enabled: false 能启动了就. 在docker安装出现这个问题,目前还没解决. 算了用win10得 ...
- 相比于python2.6,python3.0的新特性。
这篇文章主要介绍了相比于python2.6,python3.0的新特性.更详细的介绍请参见python3.0的文档. Common Stumbling Blocks 本段简单的列出容易使人出错的变动. ...
- FTP出现211-Extension supported 停止的解决方法
FTP出问题211-Extension supported 停止的解决方法 FTP出问题211-Extension supported 停止的解决方法 FLASHFXP FTP上传登录时提示Exten ...
- 解决Linux Kettle出现闪退问题
linux环境, 运行sh spoon.sh打开图形化界面时经常出现闪退情况. 报错信息如下: cfgbuilder - Warning: The configuration parameter [o ...
- Total Commander 8.52 Beta 1
Total Commander 8.52 Beta 1http://www.ghisler.com/852_b1.php 10.08.15 Release Total Commander 8.52 b ...
- Python 系列:1 - Tuples and Sequences
5.3 Tuples and Sequences We saw that lists and strings have many common properties, e.g., indexing a ...
- Spring boot中使用springfox来生成Swagger Specification小结
Rest接口对应Swagger Specification路径获取办法: 根据location的值获取api json描述文件 也许有同学会问,为什么搞的这么麻烦,api json描述文件不就是h ...
随机推荐
- Windows 10 host where Credential Guard or Device Guard is enabled fails when running Workstation (2146361)
To disable Device Guard or Credential Guard on Itanium based computers: Disable the group policy set ...
- jquery遍历之children()与find()的区别
hildren(selector) 方法是返回匹配元素集合中每个元素的所有子元素(仅儿子辈).参数可选,添加参数表示通过选择器进行过滤,对元素进行筛选. .find(selector)方法是返回匹配元 ...
- 使用TFHpple解析html
使用TFHpple解析html https://github.com/topfunky/hpple 前期准备工作 引入静态库文件 添加库文件的 header search paths(注意,必须选中 ...
- [翻译] BBCyclingLabel
BBCyclingLabel BBCyclingLabel is just like a UILabel but allows you to perform custom animations whe ...
- vs安装部署“必备”组件里面正常情况没有出现office2010 PIA组件
vs安装部署“必备”组件里面正常情况没有出现office2010 pia组件时,将 Office2010PIARedist 文件夹放在C:\Program Files\Microsoft SDKs\W ...
- WINDBG解决cpu占高的问题
https://blog.csdn.net/yenange/article/details/62886988 https://blog.csdn.net/zhushentian/article/det ...
- cpu和gpu关于图像的分工
cpu: 图像IO导入: 图像生成: 部分图片解码: gpu: 几何图像表示: 几何图像组合等处理: 部分格式图像解码: 图像的光学.几何学操控:
- Java并发案例04---生产者消费者问题03--使用ReentrantLock
/** * 面试题:写一个固定容量同步容器,拥有put和get方法,以及getCount方法, * 能够支持2个生产者线程以及10个消费者线程的阻塞调用 * * 使用wait和notify/notif ...
- jQuery UI 实例 – 切换(Toggle)
toggle()函数用于为每个匹配元素的click事件绑定轮流的处理函数. toggle()是一个特殊的事件函数,用于为匹配元素的click事件绑定多个事件处理函数.每次触发click事件时,togg ...
- 25、springboot与缓存整合Redis
默认使用ConcurrentMapCacheManager 将数据保存在下面的Map中 docker: 安装Redis: 查看官方文档: 添加约束 <dependency> <gro ...