Adding source code for chapter 8

This commit is contained in:
muassif
2021-05-31 18:04:55 +04:00
committed by GitHub
parent f88527eef4
commit ac10d74a74
13 changed files with 360 additions and 0 deletions
+13
View File
@@ -0,0 +1,13 @@
#rddtransform2.py: rdd tranformation function-map
#please ignore next 2 statements if running directly in PySpark shell
from pyspark.sql import SparkSession
spark = SparkSession.builder.master("local[*]")\
.appName("RDD Test app")\
.getOrCreate()
data = [5, 4, 6, 3, 2, 8, 9, 2, 8, 7,
8, 4, 4, 8, 2, 7, 8, 9, 6, 9]
rdd1 = spark.sparkContext.parallelize(data)
rdd2 = rdd1.filter(lambda x: x % 2 !=0 )
print(rdd2.collect())