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

intersection()

subtract()

cartesian()

内连接与外连接
join()

leftOuterJoin()

rightOuterJoin()

fullOuterJoin()

三、综合练习:学生课程分数
网盘下载sc.txt文件,通过RDD操作实现以下数据分析:
持久化 scm.cache()

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

开设了多少门课程?

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

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

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

有多少个100分?

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

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

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

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

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


每个分数+5分。mapValues(func)

求每门课的选修人数及所有人的总分。combineByKey()

求每门课的选修人数及平均分,精确到2位小数。map(),round()

求每门课的选修人数及平均分。用reduceByKey()实现,并比较与combineByKey()的异同。

结果可视化。 pyecharts.charts,Bar()

浙公网安备 33010602011771号