6. RDD综合练习:更丰富的操作

持久化 scm.cache()

 

 

 

 

 

 总共有多少学生?map(), distinct(), count()

开设了多少门课程?

 

 

 每个学生选修了多少门课?map(), countByKey()

 

 

  每门课程有多少个学生选?map(), countByValue()

 

 多少个100分?

 

 Tom选修了几门课?每门课多少分?filter(), map() RDD

 

  Tom选修了几门课?每门课多少分?map(),lookup()  list

 

 Tom的成绩按分数大小排序。filter(), map(), sortBy()

 

  Tom的平均分。map(),lookup(),mean()

 

 生成(姓名课程,分数)RDD,观察keys(),values()

 

 

每个分数+20平时分。
分别用mapValues(func)和 map(func)实现。
并查看不及格人数的变化。

变化前不及格人数

 

 mapValues(func)

 

 map(func)

 求每门课的选修人数及平均分

lookup(),np.mean()实现

 

 

 

reduceByKey()和collectAsMap()实现

 

 

 

 

combineByKey(),map(),round()实现,确到2位小数

 

 

 

 

多个考勤文件,签到日期汇总,出勤次数统计

键值对RDD的内连接与外连接

join(), leftOuterJoin(), rightOuterJoin(), fullOuterJoin()

 

posted @ 2022-04-20 19:33  郑坚林  阅读(8)  评论(0编辑  收藏  举报