当前位置:首页 - Spark

Spark distinct算子学习使用详解

作者:高景洋 日期:2020-10-25 13:31:34 浏览次数:1208

distinct:

    Rdd数据去重


示例代码:

def my_distinct():
    data = [1,2,3,4,5]
    rdd1 =sc.parallelize(data)
    data2 = [2,3,4,9,10]
    rdd2 = sc.parallelize(data2)
    result = rdd1.union(rdd2).distinct() 
 print(result.collect())

输出结果:

[10, 1, 2, 3, 4, 5, 9]



本文永久性链接:
<a href="http://r4.com.cn/art155.aspx">Spark distinct算子学习使用详解</a>
当前header:Host: r4.com.cn X-Host1: r4.com.cn X-Host2: r4.com.cn X-Host3: 127.0.0.1:8080 X-Forwarded-For: 44.210.83.132 X-Real-Ip: 44.210.83.132 X-Domain: r4.com.cn X-Request: GET /art155.aspx HTTP/1.1 X-Request-Uri: /art155.aspx Connection: close User-Agent: CCBot/2.0 (https://commoncrawl.org/faq/) Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language: en-US,en;q=0.5 If-Modified-Since: Thu, 01 Jun 2023 08:31:02 GMT Accept-Encoding: br,gzip