pyspark
文章平均质量分 82
G_scsd
决胜于千里之外,运筹于帷幄之中。
展开
-
Centos8安装CDH解决不兼容问题
Cenots8解决CDH不兼容问题原创 2022-12-04 16:27:58 · 3419 阅读 · 6 评论 -
使用python将数据导入mysql的三种方法
最近经常要将数据导入到mysql中,我写过一次后也是复制粘贴前面写过的,但老是经常忘记写过的放哪去了,索性整理下直接写到博客里面来方法: 1、使用 pymysql 库, 数据一条条插入,或者用Django ORM里面的方法,数据批量插入 2、使用 pandas 库,一次性插入 3、使用 pyspark, 一次性插入(可以不用建表,但是表没有注释, 即 mysql 的 COMMENT,要注释的话可以建空表)方法1:mysql 首先...原创 2020-06-09 21:55:08 · 17757 阅读 · 11 评论 -
hadoop上搭建spark
一、spark安装包链接:https://pan.baidu.com/s/1RyJ2I4wUlVxgaGJXtIsBNw提取码:rrzz复制这段内容后打开百度网盘手机App,操作更方便哦二、spark配置1. 上传并解压缩spark tar -xvf spark-2.4.4-bin-hadoop2.7.tgz 移动到 /usr/local/目录下 mv spark-2.4.4-bin-hadoop2.7 /usr/local/spark...原创 2020-05-24 22:40:58 · 511 阅读 · 0 评论 -
PySpark读取并清洗json文件数据
pyspark读取json文件清洗并写入json文件from pyspark.sql import SparkSessiondef getSqlAndSpark(): """ 获取SQL和Spark的对象, SQL的没写,暂时不用 :return: """ spark = SparkSession \ .builder \ ...原创 2020-04-25 21:49:14 · 3263 阅读 · 0 评论 -
PySpark读取并清洗mongoDB数据
windows下pyspark读取mongo中的数据并清洗重复数据1. mongo中样例数据// 1{ "_id": ObjectId("5e9aebe49e8fb72b646766ec"), "key": "STACEE", "name": "Observations of the BL Lacertae Object 3C 66A with STACEE",...原创 2020-04-25 21:29:20 · 1578 阅读 · 0 评论 -
PySpark RDD 之 takeSample
1. pyspark 版本 2.3.0版本2. 官网takeSample(withReplacement,num,seed=None)[source]¶Return a fixed-size sampled subset of this RDD.中文:返回此RDD的固定大小的采样子集。Note This method should only be ...原创 2019-12-23 22:01:42 · 1849 阅读 · 0 评论 -
PySpark RDD 之 foreach
1. pyspark 版本 2.3.0版本2. 官网foreach(f)[source]Applies a function to all elements of this RDD.中文:将函数应用于此RDD的所有元素。>>> def f(x): print(x)>>> sc.parallelize([1, 2, ...原创 2019-12-15 19:05:41 · 7770 阅读 · 0 评论 -
PySpark RDD 之collect、 take、top、first取值操作
1. pyspark 版本 2.3.0版本2. collect()collect()[source]Return a list that contains all of the elements in this RDD.中文:返回包含此RDD中的所有元素的列表。Note This method should only be used if the res...原创 2019-12-14 17:07:11 · 10533 阅读 · 0 评论 -
PySpark RDD 之 countByValue
1. pyspark 版本 2.3.0版本2. 官网 countByValue()[source] Return the count of each unique value in this RDD as a dictionary of (value, count) pairs. 中文:将此RDD中每个惟一值的计数作为(值、计数...原创 2019-12-12 22:18:01 · 1164 阅读 · 0 评论 -
PySpark RDD 之 reduce
1. pyspark 版本 2.3.0版本2. 官网 reduce(f)[source] Reduces the elements of this RDD using the specified commutative and associative binary operator. Currently reduces partitions lo...原创 2019-12-11 22:37:53 · 1926 阅读 · 0 评论 -
PySpark 之 连接变换 union、intersection、subtract、cartesian
1. pyspark 版本 2.3.0版本2. 解释 union() 并集 intersection() 交集 subtract() 差集 cartesian() 笛卡尔union 官网:...原创 2019-12-09 22:36:10 · 4513 阅读 · 0 评论 -
PySpark RDD 之 filter
1. pyspark 版本 2.3.0版本2. 官网filter(f)[source]Return a new RDD containing only the elements that satisfy a predicate.中文:返回仅包含满足条件的元素的新RDD。>>> rdd = sc.parallelize([1, 2, 3...原创 2019-12-08 17:34:15 · 9660 阅读 · 2 评论 -
PySpark 之 flatMap
1. pyspark 版本 2.3.0版本2. 官网flatMap(f,preservesPartitioning=False)[source] Return a new RDD by first applying a function to all elements of this RDD, and then flattening the resul...原创 2019-12-08 16:30:42 · 7562 阅读 · 0 评论 -
PySpark 之 map
1. pyspark 版本 2.3.0版本2. 官网 map(f,preservesPartitioning=False)[source] Return a new RDD by applying a function to each element of this RDD. 中文翻译:通过对这个RDD的每...原创 2019-12-08 15:30:51 · 6703 阅读 · 0 评论 -
PySpark 之 parallelize
1. pyspark 版本 2.3.0版本2. 官网 parallelize(c,numSlices=None)[source] Distribute a local Python collection to form an RDD. Using xrange is recommended if the input represents ...原创 2019-12-08 14:12:09 · 3304 阅读 · 0 评论 -
个人对 PySpark 的看法和见解
1. 介绍下为什么重新写pyspark的博客 很久没写过关于pyspark的博客了,最近工作中要用到,所以就重新捡起来了,事先说一下,我pyspark也不怎么样,一边看官网、一边自己查资料并总结出来的,有些大牛喜欢看源码,对于我们这些人来说,会用就行,什么原理暂时不说,等学会了有时间再去看,我自己从最开始的方法写起,一个算子一个博客,结合他人的思路来多方面的介绍这个算子。...原创 2019-12-07 21:16:20 · 6619 阅读 · 5 评论