国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

Python大數(shù)據(jù)之PySpark(三)使用Python語言開發(fā)Spark程序代碼

這篇具有很好參考價(jià)值的文章主要介紹了Python大數(shù)據(jù)之PySpark(三)使用Python語言開發(fā)Spark程序代碼。希望對(duì)大家有所幫助。如果存在錯(cuò)誤或未考慮完全的地方,請(qǐng)大家不吝賜教,您也可以點(diǎn)擊"舉報(bào)違法"按鈕提交疑問。

使用Python語言開發(fā)Spark程序代碼

  • Spark Standalone的PySpark的搭建----bin/pyspark --master spark://node1:7077
  • Spark StandaloneHA的搭建—Master的單點(diǎn)故障(node1,node2),zk的leader選舉機(jī)制,1-2min還原
  • 【scala版本的交互式界面】bin/spark-shell --master xxx
  • 【python版本交互式界面】bin/pyspark --master xxx
  • 【提交任務(wù)】bin/spark-submit --master xxxx

【學(xué)會(huì)配置】Windows的PySpark環(huán)境配置

  • 1-安裝Andaconda
  • 2-在Anaconda Prompt中安裝PySpark
  • windows spark python,# PySpark,python大數(shù)據(jù),大數(shù)據(jù),python,spark
  • 3-執(zhí)行安裝
  • windows spark python,# PySpark,python大數(shù)據(jù),大數(shù)據(jù),python,spark
  • 4-使用Pycharm構(gòu)建Project(準(zhǔn)備工作)
  • 需要配置anaconda的環(huán)境變量–參考課件
  • 需要配置hadoop3.3.0的安裝包,里面有winutils,防止pycharm寫代碼的過程中報(bào)錯(cuò)

補(bǔ)充:
windows spark python,# PySpark,python大數(shù)據(jù),大數(shù)據(jù),python,spark

windows spark python,# PySpark,python大數(shù)據(jù),大數(shù)據(jù),python,spark

PyCharm構(gòu)建Python project

  • 項(xiàng)目規(guī)劃
  • 項(xiàng)目名稱:Bigdata25-pyspark_3.1.2
  • windows spark python,# PySpark,python大數(shù)據(jù),大數(shù)據(jù),python,spark
  • 模塊名稱:PySpark-SparkBase_3.1.2,PySpark-SparkCore_3.1.2,PySpark-SparkSQL_3.1.2
  • windows spark python,# PySpark,python大數(shù)據(jù),大數(shù)據(jù),python,spark
  • 文件夾:
  • main pyspark的代碼
  • data 數(shù)據(jù)文件
  • config 配置文件
  • test 常見python測(cè)試代碼放在test中

應(yīng)用入口:SparkContext

  • http://spark.apache.org/docs/latest/rdd-programming-guide.html
  • windows spark python,# PySpark,python大數(shù)據(jù),大數(shù)據(jù),python,spark
  • windows spark python,# PySpark,python大數(shù)據(jù),大數(shù)據(jù),python,spark

WordCount代碼實(shí)戰(zhàn)

  • 需求:給你一個(gè)文本文件,統(tǒng)計(jì)出單詞的數(shù)量

  • 算子:rdd的api的操作,就是算子,flatMap扁平化算子,map轉(zhuǎn)換算子

  • Transformation算子

  • Action算子

  • 步驟:

  • 1-首先創(chuàng)建SparkContext上下文環(huán)境
    2-從外部文件數(shù)據(jù)源讀取數(shù)據(jù)
    3-執(zhí)行flatmap執(zhí)行扁平化操作
    4-執(zhí)行map轉(zhuǎn)化操作,得到(word,1)
    5-reduceByKey將相同Key的Value數(shù)據(jù)累加操作
    6-將結(jié)果輸出到文件系統(tǒng)或打印

  • 代碼:

# -*- coding: utf-8 -*-
# Program function: Spark的第一個(gè)程序
# 1-思考:sparkconf和sparkcontext從哪里導(dǎo)保
# 2-如何理解算子?Spark中算子有2種,
# 一種稱之為Transformation算子(flatMapRDD-mapRDD-reduceBykeyRDD),
# 一種稱之為Action算子(輸出到控制臺(tái),或文件系統(tǒng)或hdfs),比如collect或saveAsTextFile都是Action算子
from pyspark import SparkConf,SparkContext

if __name__ == '__main__':
   # 1 - 首先創(chuàng)建SparkContext上下文環(huán)境
   conf = SparkConf().setAppName("FirstSpark").setMaster("local[*]")
   sc = SparkContext(conf=conf)
   sc.setLogLevel("WARN")#日志輸出級(jí)別
   # 2 - 從外部文件數(shù)據(jù)源讀取數(shù)據(jù)
   fileRDD = sc.textFile("D:\BigData\PyWorkspace\Bigdata25-pyspark_3.1.2\PySpark-SparkBase_3.1.2\data\words.txt")
   # print(type(fileRDD))#<class 'pyspark.rdd.RDD'>
   # all the data is loaded into the driver's memory.
   # print(fileRDD.collect())
   # ['hello you Spark Flink', 'hello me hello she Spark']
   # 3 - 執(zhí)行flatmap執(zhí)行扁平化操作
   flat_mapRDD = fileRDD.flatMap(lambda words: words.split(" "))
   # print(type(flat_mapRDD))
   # print(flat_mapRDD.collect())
   #['hello', 'you', 'Spark', 'Flink', 'hello', 'me', 'hello', 'she', 'Spark']
   # # 4 - 執(zhí)行map轉(zhuǎn)化操作,得到(word, 1)
   rdd_mapRDD = flat_mapRDD.map(lambda word: (word, 1))
   # print(type(rdd_mapRDD))#<class 'pyspark.rdd.PipelinedRDD'>
   # print(rdd_mapRDD.collect())
   # [('hello', 1), ('you', 1), ('Spark', 1), ('Flink', 1), ('hello', 1), ('me', 1), ('hello', 1), ('she', 1), ('Spark', 1)]
   # 5 - reduceByKey將相同Key的Value數(shù)據(jù)累加操作
   resultRDD = rdd_mapRDD.reduceByKey(lambda x, y: x + y)
   # print(type(resultRDD))
   # print(resultRDD.collect())
   # [('Spark', 2), ('Flink', 1), ('hello', 3), ('you', 1), ('me', 1), ('she', 1)]
   # 6 - 將結(jié)果輸出到文件系統(tǒng)或打印
   resultRDD.saveAsTextFile("D:\BigData\PyWorkspace\Bigdata25-pyspark_3.1.2\PySpark-SparkBase_3.1.2\data\output\wordsAdd")
   # 7-停止SparkContext
   sc.stop()#Shut down the SparkContext.

  • 總結(jié):

  • windows spark python,# PySpark,python大數(shù)據(jù),大數(shù)據(jù),python,spark

TopK需求

需求:[(‘Spark’, 2), (‘Flink’, 1), (‘hello’, 3), (‘you’, 1), (‘me’, 1), (‘she’, 1)]

排序:[ (‘hello’, 3),(‘Spark’, 2),]

共識(shí):Spark核心或靈魂是rdd,spark的所有操作都是基于rdd的操作

代碼:

# -*- coding: utf-8 -*-
# Program function: 針對(duì)于value單詞統(tǒng)計(jì)計(jì)數(shù)的排序
# 1-思考:sparkconf和sparkcontext從哪里導(dǎo)保
# 2-如何理解算子?Spark中算子有2種,
# 一種稱之為Transformation算子(flatMapRDD-mapRDD-reduceBykeyRDD),
# 一種稱之為Action算子(輸出到控制臺(tái),或文件系統(tǒng)或hdfs),比如collect或saveAsTextFile都是Action算子
from pyspark import SparkConf, SparkContext

if __name__ == '__main__':
# 1 - 首先創(chuàng)建SparkContext上下文環(huán)境
conf = SparkConf().setAppName("FirstSpark").setMaster("local[*]")
sc = SparkContext(conf=conf)
sc.setLogLevel("WARN")  # 日志輸出級(jí)別
# 2 - 從外部文件數(shù)據(jù)源讀取數(shù)據(jù)
fileRDD = sc.textFile("D:\BigData\PyWorkspace\Bigdata25-pyspark_3.1.2\PySpark-SparkBase_3.1.2\data\words.txt")
# print(type(fileRDD))#<class 'pyspark.rdd.RDD'>
# all the data is loaded into the driver's memory.
# print(fileRDD.collect())
# ['hello you Spark Flink', 'hello me hello she Spark']
# 3 - 執(zhí)行flatmap執(zhí)行扁平化操作
flat_mapRDD = fileRDD.flatMap(lambda words: words.split(" "))
# print(type(flat_mapRDD))
# print(flat_mapRDD.collect())
# ['hello', 'you', 'Spark', 'Flink', 'hello', 'me', 'hello', 'she', 'Spark']
# # 4 - 執(zhí)行map轉(zhuǎn)化操作,得到(word, 1)
rdd_mapRDD = flat_mapRDD.map(lambda word: (word, 1))
# print(type(rdd_mapRDD))#<class 'pyspark.rdd.PipelinedRDD'>
# print(rdd_mapRDD.collect())
# [('hello', 1), ('you', 1), ('Spark', 1), ('Flink', 1), ('hello', 1), ('me', 1), ('hello', 1), ('she', 1), ('Spark', 1)]
# 5 - reduceByKey將相同Key的Value數(shù)據(jù)累加操作
resultRDD = rdd_mapRDD.reduceByKey(lambda x, y: x + y)
# print(type(resultRDD))
print(resultRDD.collect())
# [('Spark', 2), ('Flink', 1), ('hello', 3), ('you', 1), ('me', 1), ('she', 1)]
# 6 針對(duì)于value單詞統(tǒng)計(jì)計(jì)數(shù)的排序
print("==============================sortBY=============================")
print(resultRDD.sortBy(lambda x: x[1], ascending=False).take(3))
# [('hello', 3), ('Spark', 2), ('Flink', 1)]
print(resultRDD.sortBy(lambda x: x[1], ascending=False).top(3, lambda x: x[1]))
print("==============================sortBykey=============================")
print(resultRDD.map(lambda x: (x[1], x[0])).collect())
# [(2, 'Spark'), (1, 'Flink'), (3, 'hello'), (1, 'you'), (1, 'me'), (1, 'she')]
print(resultRDD.map(lambda x: (x[1], x[0])).sortByKey(False).take(3))
#[(3, 'hello'), (2, 'Spark'), (1, 'Flink')]
# 7-停止SparkContext
sc.stop()  # Shut down the SparkContext.

  • sortBy
  • sortByKey操作

從HDFS讀取數(shù)據(jù)

# -*- coding: utf-8 -*-
# Program function: 從HDFS讀取文件

from pyspark import SparkConf, SparkContext
import time
if __name__ == '__main__':
 # 1 - 首先創(chuàng)建SparkContext上下文環(huán)境
 conf = SparkConf().setAppName("FromHDFS").setMaster("local[*]")
 sc = SparkContext(conf=conf)
 sc.setLogLevel("WARN")  # 日志輸出級(jí)別
 # 2 - 從外部文件數(shù)據(jù)源讀取數(shù)據(jù)
 fileRDD = sc.textFile("hdfs://node1:9820/pydata/input/hello.txt")
 # ['hello you Spark Flink', 'hello me hello she Spark']
 # 3 - 執(zhí)行flatmap執(zhí)行扁平化操作
 flat_mapRDD = fileRDD.flatMap(lambda words: words.split(" "))
 # ['hello', 'you', 'Spark', 'Flink', 'hello', 'me', 'hello', 'she', 'Spark']
 # # 4 - 執(zhí)行map轉(zhuǎn)化操作,得到(word, 1)
 rdd_mapRDD = flat_mapRDD.map(lambda word: (word, 1))
 # [('hello', 1), ('you', 1), ('Spark', 1), ('Flink', 1), ('hello', 1), ('me', 1), ('hello', 1), ('she', 1), ('Spark', 1)]
 # 5 - reduceByKey將相同Key的Value數(shù)據(jù)累加操作
 resultRDD = rdd_mapRDD.reduceByKey(lambda x, y: x + y)
 # print(type(resultRDD))
 print(resultRDD.collect())

 # 休息幾分鐘
 time.sleep(600)

 # 7-停止SparkContext
 sc.stop()  # Shut down the SparkContext.
  • windows spark python,# PySpark,python大數(shù)據(jù),大數(shù)據(jù),python,spark


提交代碼到集群執(zhí)行

  • 關(guān)鍵:sys.argv[1],

  • 代碼:

# -*- coding: utf-8 -*-
# Program function: 提交任務(wù)執(zhí)行

import sys

from pyspark import SparkConf, SparkContext

if __name__ == '__main__':
   # 1 - 首先創(chuàng)建SparkContext上下文環(huán)境
   conf = SparkConf().setAppName("FromHDFS").setMaster("local[*]")
   sc = SparkContext(conf=conf)
   sc.setLogLevel("WARN")  # 日志輸出級(jí)別
   # 2 - 從外部文件數(shù)據(jù)源讀取數(shù)據(jù)
   # hdfs://node1:9820/pydata/input/hello.txt
   fileRDD = sc.textFile(sys.argv[1])
   # ['hello you Spark Flink', 'hello me hello she Spark']
   # 3 - 執(zhí)行flatmap執(zhí)行扁平化操作
   flat_mapRDD = fileRDD.flatMap(lambda words: words.split(" "))
   # ['hello', 'you', 'Spark', 'Flink', 'hello', 'me', 'hello', 'she', 'Spark']
   # # 4 - 執(zhí)行map轉(zhuǎn)化操作,得到(word, 1)
   rdd_mapRDD = flat_mapRDD.map(lambda word: (word, 1))
   # [('hello', 1), ('you', 1), ('Spark', 1), ('Flink', 1), ('hello', 1), ('me', 1), ('hello', 1), ('she', 1), ('Spark', 1)]
   # 5 - reduceByKey將相同Key的Value數(shù)據(jù)累加操作
   resultRDD = rdd_mapRDD.reduceByKey(lambda x, y: x + y)
   # print(type(resultRDD))
   resultRDD.saveAsTextFile(sys.argv[2])
   # 7-停止SparkContext
   sc.stop()  # Shut down the SparkContext.

  • 結(jié)果:

  • windows spark python,# PySpark,python大數(shù)據(jù),大數(shù)據(jù),python,spark

[掌握-擴(kuò)展閱讀]遠(yuǎn)程PySpark環(huán)境配置

  • 需求:需要將PyCharm連接服務(wù)器,同步本地寫的代碼到服務(wù)器上,使用服務(wù)器上的Python解析器執(zhí)行

  • 步驟:

  • 1-準(zhǔn)備PyCharm的連接

  • windows spark python,# PySpark,python大數(shù)據(jù),大數(shù)據(jù),python,spark

  • 2-需要了解服務(wù)器的地址,端口號(hào),用戶名,密碼

  • windows spark python,# PySpark,python大數(shù)據(jù),大數(shù)據(jù),python,spark

  • windows spark python,# PySpark,python大數(shù)據(jù),大數(shù)據(jù),python,spark

  • windows spark python,# PySpark,python大數(shù)據(jù),大數(shù)據(jù),python,spark
  • 設(shè)置自動(dòng)的上傳,如果不太好使,重啟pycharm

  • windows spark python,# PySpark,python大數(shù)據(jù),大數(shù)據(jù),python,spark

  • 3-pycharm讀取的文件都需要上傳到linux中,復(fù)制相對(duì)路徑

  • windows spark python,# PySpark,python大數(shù)據(jù),大數(shù)據(jù),python,spark

  • 4-執(zhí)行代碼在遠(yuǎn)程服務(wù)器上

  • windows spark python,# PySpark,python大數(shù)據(jù),大數(shù)據(jù),python,spark
  • 5-執(zhí)行代碼

# -*- coding: utf-8 -*-
# Program function: Spark的第一個(gè)程序
# 1-思考:sparkconf和sparkcontext從哪里導(dǎo)保
# 2-如何理解算子?Spark中算子有2種,
# 一種稱之為Transformation算子(flatMapRDD-mapRDD-reduceBykeyRDD),
# 一種稱之為Action算子(輸出到控制臺(tái),或文件系統(tǒng)或hdfs),比如collect或saveAsTextFile都是Action算子
from pyspark import SparkConf, SparkContext

if __name__ == '__main__':
 # 1 - 首先創(chuàng)建SparkContext上下文環(huán)境
 conf = SparkConf().setAppName("FirstSpark").setMaster("local[*]")
 sc = SparkContext(conf=conf)
 sc.setLogLevel("WARN")  # 日志輸出級(jí)別
 # 2 - 從外部文件數(shù)據(jù)源讀取數(shù)據(jù)
 fileRDD = sc.textFile("/export/data/pyspark_workspace/PySpark-SparkBase_3.1.2/data/words.txt")
 # fileRDD = sc.parallelize(["hello you", "hello me", "hello spark"])
 # 3 - 執(zhí)行flatmap執(zhí)行扁平化操作
 flat_mapRDD = fileRDD.flatMap(lambda words: words.split(" "))
 # print(type(flat_mapRDD))
 # print(flat_mapRDD.collect())
 # ['hello', 'you', 'Spark', 'Flink', 'hello', 'me', 'hello', 'she', 'Spark']
 # # 4 - 執(zhí)行map轉(zhuǎn)化操作,得到(word, 1)
 rdd_mapRDD = flat_mapRDD.map(lambda word: (word, 1))
 # print(type(rdd_mapRDD))#<class 'pyspark.rdd.PipelinedRDD'>
 # print(rdd_mapRDD.collect())
 # [('hello', 1), ('you', 1), ('Spark', 1), ('Flink', 1), ('hello', 1), ('me', 1), ('hello', 1), ('she', 1), ('Spark', 1)]
 # 5 - reduceByKey將相同Key的Value數(shù)據(jù)累加操作
 resultRDD = rdd_mapRDD.reduceByKey(lambda x, y: x + y)
 # print(type(resultRDD))
 print(resultRDD.collect())
 # [('Spark', 2), ('Flink', 1), ('hello', 3), ('you', 1), ('me', 1), ('she', 1)]
 # 6 - 將結(jié)果輸出到文件系統(tǒng)或打印
 # resultRDD.saveAsTextFile("D:\BigData\PyWorkspace\Bigdata25-pyspark_3.1.2\PySpark-SparkBase_3.1.2\data\output\wordsAdd")
 # 7-停止SparkContext
 sc.stop()  # Shut down the SparkContext.

  • 切記忘記上傳python的文件,直接執(zhí)行

  • 注意1:自動(dòng)上傳設(shè)置

  • windows spark python,# PySpark,python大數(shù)據(jù),大數(shù)據(jù),python,spark

  • 注意2:增加如何使用standalone和HA的方式提交代碼執(zhí)行

  • 但是需要注意,盡可能使用hdfs的文件,不要使用單機(jī)版本的文件,因?yàn)閟tandalone是集群模式

# -*- coding: utf-8 -*-

# Program function: Spark的第一個(gè)程序

# 1-思考:sparkconf和sparkcontext從哪里導(dǎo)保

# 2-如何理解算子?Spark中算子有2種,

# 一種稱之為Transformation算子(flatMapRDD-mapRDD-reduceBykeyRDD),

# 一種稱之為Action算子(輸出到控制臺(tái),或文件系統(tǒng)或hdfs),比如collect或saveAsTextFile都是Action算子

>from pyspark import SparkConf, SparkContext
>
>if __name__ == '__main__':
>
># 1 - 首先創(chuàng)建SparkContext上下文環(huán)境
>
>conf = SparkConf().setAppName("FirstSpark").setMaster("spark://node1:7077,node2:7077")
>sc = SparkContext(conf=conf)
>sc.setLogLevel("WARN")  # 日志輸出級(jí)別
>
># 2 - 從外部文件數(shù)據(jù)源讀取數(shù)據(jù)
>
>fileRDD = sc.textFile("hdfs://node1:9820/pydata/input/hello.txt")
>
># fileRDD = sc.parallelize(["hello you", "hello me", "hello spark"])
>
># 3 - 執(zhí)行flatmap執(zhí)行扁平化操作
>
>flat_mapRDD = fileRDD.flatMap(lambda words: words.split(" "))
>
># print(type(flat_mapRDD))
>
># print(flat_mapRDD.collect())
>
># ['hello', 'you', 'Spark', 'Flink', 'hello', 'me', 'hello', 'she', 'Spark']
>
># # 4 - 執(zhí)行map轉(zhuǎn)化操作,得到(word, 1)
>
>rdd_mapRDD = flat_mapRDD.map(lambda word: (word, 1))
>
># print(type(rdd_mapRDD))#<class 'pyspark.rdd.PipelinedRDD'>
>
># print(rdd_mapRDD.collect())
>
># [('hello', 1), ('you', 1), ('Spark', 1), ('Flink', 1), ('hello', 1), ('me', 1), ('hello', 1), ('she', 1), ('Spark', 1)]
>
># 5 - reduceByKey將相同Key的Value數(shù)據(jù)累加操作
>
>resultRDD = rdd_mapRDD.reduceByKey(lambda x, y: x + y)
>
># print(type(resultRDD))
>
>print(resultRDD.collect())
>
># [('Spark', 2), ('Flink', 1), ('hello', 3), ('you', 1), ('me', 1), ('she', 1)]
>
># 6 - 將結(jié)果輸出到文件系統(tǒng)或打印
>
># resultRDD.saveAsTextFile("D:\BigData\PyWorkspace\Bigdata25-pyspark_3.1.2\PySpark-SparkBase_3.1.2\data\output\wordsAdd")
>
># 7-停止SparkContext
>
>sc.stop()  # Shut down the SparkContext.

總結(jié)

  • 函數(shù)式編程

  • #Python中的函數(shù)式編程
    #1-map(func, *iterables) --> map object
    def fun(x):
        return x*x
    #x=[1,2,3,4,5] y=map(fun,[1,2,3,4,5]) #[1, 4, 9, 16, 25]
    print(list(map(fun, [1, 2, 3, 4, 5])))
    #2-lambda 匿名函數(shù)  java: x=>x*x 表達(dá)式  Scala:x->x*x
    g=lambda x:x*x
    print(g(10))
    print(list(map(lambda x:x*x, [1, 2, 3, 4, 5])))
    def add(x,y):
        return x+y
    
    print(list(map(add, range(5), range(5, 10))))
    print(list(map(lambda x,y:x+y,range(5),range(5,10))))
    #3- [add(x,y) for x,y in zip(range(5),range(5,10))]
    
    # print(list(zip([1, 2, 3], [4, 5, 6])))#[1,4],[2,5]
    # print(list(zip([1, 2, 3], [4, 5, 6,7])))#[1,4],[2,5]
    # print(list(zip([1, 2, 3,6], [4, 5, 6])))#[1,4],[2,5]
    
    # 語法 lambda表達(dá)式語言:【lambda 變量:表達(dá)式】
    # 列表表達(dá)式 [表達(dá)式 for 變量 in 可迭代的序列中 if 條件]
    print([add(x, y) for x, y in zip(range(5), range(5))])
    #[0, 2, 4, 6, 8]
    #3-reduce
    from functools import  reduce
    # ((((1+2)+3)+4)+5)
    print(reduce(lambda x, y: x + y, [1, 2, 3, 4, 5]))
    
    
    
    # 4-filter
    seq1=['foo','x41','?1','***']
    def func(x):
        #Return True if the string is an alpha-numeric string
        return x.isalnum()
    print(list(filter(func,seq1))) #返回 filter 對(duì)象
    
    # sorted()
    # 最后我們可以看到,函數(shù)式編程有如下好處:
    # 1)代碼更簡(jiǎn)單了。
    # 2)數(shù)據(jù)集,操作,返回值都放到了一起。
    # 3)你在讀代碼的時(shí)候,沒有了循環(huán)體,于是就可以少了些臨時(shí)變量,以及變量倒來倒去邏輯。
    # 4)你的代碼變成了在描述你要干什么,而不是怎么去干。
    

    后記

??博客主頁:https://manor.blog.csdn.net

??歡迎點(diǎn)贊 ?? 收藏 ?留言 ?? 如有錯(cuò)誤敬請(qǐng)指正!
??本文由 Maynor 原創(chuàng),首發(fā)于 CSDN博客??
??感覺這輩子,最深情綿長的注視,都給了手機(jī)?
??專欄持續(xù)更新,歡迎訂閱:https://blog.csdn.net/xianyu120/category_12453356.html文章來源地址http://www.zghlxwxcb.cn/news/detail-795726.html

到了這里,關(guān)于Python大數(shù)據(jù)之PySpark(三)使用Python語言開發(fā)Spark程序代碼的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點(diǎn)僅代表作者本人,不代表本站立場(chǎng)。本站僅提供信息存儲(chǔ)空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請(qǐng)注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實(shí)不符,請(qǐng)點(diǎn)擊違法舉報(bào)進(jìn)行投訴反饋,一經(jīng)查實(shí),立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費(fèi)用

相關(guān)文章

  • 《PySpark大數(shù)據(jù)分析實(shí)戰(zhàn)》-12.Spark on YARN配置Spark運(yùn)行在YARN上

    《PySpark大數(shù)據(jù)分析實(shí)戰(zhàn)》-12.Spark on YARN配置Spark運(yùn)行在YARN上

    ?? 博主簡(jiǎn)介 ?? 作者簡(jiǎn)介:大家好,我是wux_labs。?? 熱衷于各種主流技術(shù),熱愛數(shù)據(jù)科學(xué)、機(jī)器學(xué)習(xí)、云計(jì)算、人工智能。 通過了TiDB數(shù)據(jù)庫專員(PCTA)、TiDB數(shù)據(jù)庫專家(PCTP)、TiDB數(shù)據(jù)庫認(rèn)證SQL開發(fā)專家(PCSD)認(rèn)證。 通過了微軟Azure開發(fā)人員、Azure數(shù)據(jù)工程師、Azure解決

    2024年02月03日
    瀏覽(49)
  • 林子雨 VirtualBox + Ubuntu[linux] 配置 java、hadoop、Spark[python]、pyspark快速配置流程

    林子雨 VirtualBox + Ubuntu[linux] 配置 java、hadoop、Spark[python]、pyspark快速配置流程

    按照步驟快速執(zhí)行shell,最快速配置。 讀者可以根據(jù)該篇隨記快速回顧流程,以及用到的shell指令和相關(guān)配置文件。 是林老師教程的精簡(jiǎn)版,初次配置者只能作為流程參考,主要和林子雨Spark[python]版課程配套。 ?林老師廈大實(shí)驗(yàn)指南鏈接如下: Spark編程基礎(chǔ)(Python版)教材官

    2024年04月12日
    瀏覽(25)
  • 【Python】PySpark 數(shù)據(jù)計(jì)算 ③ ( RDD#reduceByKey 函數(shù)概念 | RDD#reduceByKey 方法工作流程 | RDD#reduceByKey 語法 | 代碼示例 )

    【Python】PySpark 數(shù)據(jù)計(jì)算 ③ ( RDD#reduceByKey 函數(shù)概念 | RDD#reduceByKey 方法工作流程 | RDD#reduceByKey 語法 | 代碼示例 )

    RDD#reduceByKey 方法 是 PySpark 中 提供的計(jì)算方法 , 首先 , 對(duì) 鍵值對(duì) KV 類型 RDD 對(duì)象 數(shù)據(jù) 中 相同 鍵 key 對(duì)應(yīng)的 值 value 進(jìn)行分組 , 然后 , 按照 開發(fā)者 提供的 算子 ( 邏輯 / 函數(shù) ) 進(jìn)行 聚合操作 ; 上面提到的 鍵值對(duì) KV 型 的數(shù)據(jù) , 指的是 二元元組 , 也就是 RDD 對(duì)象中存儲(chǔ)的數(shù)據(jù)是

    2024年02月14日
    瀏覽(26)
  • spark底層為什么選擇使用scala語言開發(fā)

    基于Scala的語言特性 集成性:Scala 是一種運(yùn)行在 Java 虛擬機(jī)(JVM)上的靜態(tài)類型編程語言,可以與 Java 代碼無縫集成。由于 Spark 涉及到與大量 Java 生態(tài)系統(tǒng)的交互,例如 Hadoop、Hive 等,使用 Scala 可以方便地與這些組件進(jìn)行集成和交互。 函數(shù)式編程支持:Scala 是一種面向函數(shù)

    2024年02月10日
    瀏覽(35)
  • Spark使用Python開發(fā)和RDD

    Spark使用Python開發(fā)和RDD

    在所有節(jié)點(diǎn)上按照python3,版本必須是python3.6及以上版本 修改所有節(jié)點(diǎn)的環(huán)境變量 在pyspark shell使用python編寫wordcount RDD的全稱為Resilient Distributed Dataset,是一個(gè)彈性、可復(fù)原的分布式數(shù)據(jù)集,是Spark中最基本的抽象,是一個(gè)不可變的、有多個(gè)分區(qū)的、可以并行計(jì)算的集合。RDD中

    2024年02月11日
    瀏覽(26)
  • 使用Pycharm運(yùn)行spark實(shí)例時(shí)沒有pyspark包(ModuleNotFoundError: No module named ‘py4j‘)

    使用Pycharm運(yùn)行spark實(shí)例時(shí)沒有pyspark包(ModuleNotFoundError: No module named ‘py4j‘)

    在安裝并配置pyspark,下載并打開Pycharm(專業(yè)版)后進(jìn)行spark實(shí)例操作(筆者以統(tǒng)計(jì)文件中的行數(shù)為例)時(shí),運(yùn)行程序后提示ModuleNotFoundError: No module named \\\'py4j\\\': 1.下載py4j包后下載pyspark包 打開新終端,在終端中輸入(若在pycharm中進(jìn)行下載可能導(dǎo)致下載失敗,這里指定使用清華

    2024年04月26日
    瀏覽(46)
  • 【Python】PySpark 數(shù)據(jù)處理 ② ( 安裝 PySpark | PySpark 數(shù)據(jù)處理步驟 | 構(gòu)建 PySpark 執(zhí)行環(huán)境入口對(duì)象 )

    【Python】PySpark 數(shù)據(jù)處理 ② ( 安裝 PySpark | PySpark 數(shù)據(jù)處理步驟 | 構(gòu)建 PySpark 執(zhí)行環(huán)境入口對(duì)象 )

    執(zhí)行 Windows + R , 運(yùn)行 cmd 命令行提示符 , 在命令行提示符終端中 , 執(zhí)行 命令 , 安裝 PySpark , 安裝過程中 , 需要下載 310 M 的安裝包 , 耐心等待 ; 安裝完畢 : 命令行輸出 : 如果使用 官方的源 下載安裝 PySpark 的速度太慢 , 可以使用 國內(nèi)的 鏡像網(wǎng)站 https://pypi.tuna.tsinghua.edu.cn/simple

    2024年02月06日
    瀏覽(23)
  • Python大數(shù)據(jù)之PySpark(二)PySpark安裝

    Python大數(shù)據(jù)之PySpark(二)PySpark安裝

    1-明確PyPi庫,Python Package Index 所有的Python包都從這里下載,包括pyspark 2-為什么PySpark逐漸成為主流? http://spark.apache.org/releases/spark-release-3-0-0.html Python is now the most widely used language on Spark. PySpark has more than 5 million monthly downloads on PyPI, the Python Package Index. 記住如果安裝特定的版本

    2024年02月04日
    瀏覽(40)
  • Spark與PySpark(1.概述、框架、模塊)

    Spark與PySpark(1.概述、框架、模塊)

    目錄 1.Spark 概念 2. Hadoop和Spark的對(duì)比 3. Spark特點(diǎn) 3.1?運(yùn)行速度快 3.2 簡(jiǎn)單易用 3.3?通用性強(qiáng) 3.4?可以允許運(yùn)行在很多地方 4. Spark框架模塊 4.1 Spark Core 4.2?SparkSQL 4.3?SparkStreaming 4.4?MLlib 4.5?GraphX 5. Spark的運(yùn)行模式 5.1 本地模式(單機(jī)) Local運(yùn)行模式 5.2 Standalone模式(集群) 5.3 Hado

    2024年02月02日
    瀏覽(58)
  • 【Python使用】嘿馬頭條完整開發(fā)md筆記第2篇:數(shù)據(jù)庫,作用【附代碼文檔】

    【Python使用】嘿馬頭條完整開發(fā)md筆記第2篇:數(shù)據(jù)庫,作用【附代碼文檔】

    嘿馬頭條項(xiàng)目從到完整開發(fā)筆記總結(jié)完整教程(附代碼資料)主要內(nèi)容講述:課程簡(jiǎn)介,ToutiaoWeb虛擬機(jī)使用說明,Pycharm遠(yuǎn)程開發(fā),產(chǎn)品與開發(fā),數(shù)據(jù)庫1 產(chǎn)品介紹,2 原型圖與UI圖,3 技術(shù)架構(gòu),4 開發(fā)。OSS對(duì)象存儲(chǔ),七牛云存儲(chǔ),CDN,緩存。緩存,緩存架構(gòu),緩存數(shù)據(jù),緩存有效

    2024年03月18日
    瀏覽(28)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請(qǐng)作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包