>>> v=sc.parallelize(["one", "two", "two", "three", "three", "three"])
>>> v2=v.map(lambda x: (x,1))
>>> v2.collect()
[('one', 1), ('two', 1), ('two', 1), ('three', 1), ('three', 1), ('three', 1)]
>>> v3=v2.groupByKey()
>>> v3.collect()
[('one', <pyspark.resultiterable.ResultIterable object at 0x7fd3c7850e90>), ('two', <pyspark.resultiterable.ResultIterable object at 0x7fd3c7850f10>), ('three', <pyspark.resultiterable.ResultIterable object at 0x7fd3c6dc83d0>)]
>>> v4=v3.filter(lambda x:len(x[1].data)>2)
>>> v4.collect()
[('three', <pyspark.resultiterable.ResultIterable object at 0x7fd3c6dc8510>)]

过滤了出现次数大于2的结果。

最新文章

  1. VVDocumenter 注释工具的使用
  2. 【leetcode❤python】 112. Path Sum
  3. spring mvc 异常统一处理方式
  4. 【转】JavaScript系列文章:自动类型转换
  5. Java中char占用几个字节
  6. salesforce 零基础学习(六十八)http callout test class写法
  7. javascript 函数和作用域(函数,this)(六)
  8. 与redmine对接
  9. 【并查集】HDU 1325 Is It A Tree?
  10. POJ2503-Babelfish-二分
  11. PTA4
  12. 7、...arg ...[1,2,3] 数组扩展
  13. ELK收集tomcat访问日志并存取mysql数据库案例
  14. CSS3之box-sizing属性
  15. window下配置SSH连接GitHub、GitHub配置ssh key
  16. Linux基础知识之用户和用户组以及 Linux 权限管理
  17. $使用dom4j可解析 返回&amp;#x等字样的 html转义字符【转】
  18. 关于Jedis连接Linux上的redis出现 DENIED Redis is running in protected mode问题的解决方案
  19. hung task机制
  20. centos7修改默认运行级别的变化

热门文章

  1. C++函数的导出与导入
  2. n个骰子,和为x的概率分别是多少
  3. hello world to php( mac 配置 xmapp virtual host)
  4. nodeJS npm grunt grunt-cli
  5. HD-ACM算法专攻系列(8)——排序
  6. 持久层框架Clone
  7. 你不知道的JavaScript博文参考书籍
  8. Linux与Windows信息交互快捷方法
  9. HDU 1950 Bridging signals【最长上升序列】
  10. vue.js---methods中一个方法调用另一个方法