Featured Article

What Is RDD In PySpark With Example: Ultimate Guide

Kenneth Jul 13, 2026

In the realm of big data processing, PySpark is a powerful tool that enables users to perform transformations and analytical operations on large datasets. Among its many features, PySpark's Resilient Distributed Datasets (RDD) is a fundamental concept that deserves a closer look.

Difference between DataFrame, Dataset, and RDD in Spark
Difference between DataFrame, Dataset, and RDD in Spark

RDDs are the cornerstone of PySpark's functionality, offering a robust way to process and manipulate data across a cluster of nodes. They are immutable, partitioned collections of elements that can be operated on in parallel across nodes in a cluster.

Day 7 of #100DaysOfPyTorch  Today we learned how to save and load PyTorch models, which is crucial for real-world projects.  Step-by-step:  1️⃣ state_dict: Contains all model parameters like weights and biases.  2️⃣ Saving: Use torch.save(model.state_dict(), filename) to store parameters.  3️⃣ Loading: Create a new model instance and load parameters using load_state_dict.  4️⃣ Evaluation mode: Use .eval() for inference to disable dropout/batchnorm effects.  5️⃣ Use case: Resume training, shar... How To Start With Pytorch, Pytorch Logo, Python Range Function Tutorial, Python Code For Deploying Model, Machine Learning Model Evaluation Python, Python Range Function Explanation, Leet Code, Torch.nn Module Python, Python Range Function Guide
Day 7 of #100DaysOfPyTorch Today we learned how to save and load PyTorch models, which is crucial for real-world projects. Step-by-step: 1️⃣ state_dict: Contains all model parameters like weights and biases. 2️⃣ Saving: Use torch.save(model.state_dict(), filename) to store parameters. 3️⃣ Loading: Create a new model instance and load parameters using load_state_dict. 4️⃣ Evaluation mode: Use .eval() for inference to disable dropout/batchnorm effects. 5️⃣ Use case: Resume training, shar... How To Start With Pytorch, Pytorch Logo, Python Range Function Tutorial, Python Code For Deploying Model, Machine Learning Model Evaluation Python, Python Range Function Explanation, Leet Code, Torch.nn Module Python, Python Range Function Guide

Understanding Resilient Distributed Datasets (RDDs)

RDDs are created from Hadoop InputFormat or by dividing an existing RDD using operations such as `map`, `filter`, or `flatMap`. They preserve both the results of a transformation and the transformation itself, which allows recomputation of lost results in case of node failures.

Brij kishore Pandey on LinkedIn: 𝗠𝗮𝘀𝘁𝗲𝗿𝗶𝗻𝗴 𝗗𝗲𝘃𝗢𝗽𝘀: 𝗔 𝗩𝗶𝘀𝘂𝗮𝗹 𝗚𝘂𝗶𝗱𝗲 This roadmap… | 27 comments
Brij kishore Pandey on LinkedIn: 𝗠𝗮𝘀𝘁𝗲𝗿𝗶𝗻𝗴 𝗗𝗲𝘃𝗢𝗽𝘀: 𝗔 𝗩𝗶𝘀𝘂𝗮𝗹 𝗚𝘂𝗶𝗱𝗲 This roadmap… | 27 comments

RDDs are partitioned across the nodes in a cluster, and each node has a partition of the RDD. This partitioning ensures that computations can be performed in parallel, speeding up data processing.

RDD Creation

Rocky Bhatia on LinkedIn: 𝐄𝐱𝐜𝐢𝐭𝐞𝐝 𝐚𝐛𝐨𝐮𝐭 𝐃𝐞𝐯𝐎𝐩𝐬?  Ready to embark on a journey of… | 31 comments
Rocky Bhatia on LinkedIn: 𝐄𝐱𝐜𝐢𝐭𝐞𝐝 𝐚𝐛𝐨𝐮𝐭 𝐃𝐞𝐯𝐎𝐩𝐬? Ready to embark on a journey of… | 31 comments

Method 1: RDDs can be created from an existing RDD by applying transformations. For example, you can create a new RDD by filtering an existing one:

rdd = sc.textFile("path/to/data") filtered_rdd = rdd.filter(lambda x: "keyword" in x)

Here, `filtered_rdd` is a new RDD created by applying the `filter` transformation to `rdd`.

RDD Actions

Pinball Game development using Python
Pinball Game development using Python

Method 2: RDDs can also be created from Hadoop InputFormat using `SparkContext.textFile`, `SparkContext.halfsRDD`, and other input data source methods. Here's an example of creating an RDD from a text file:

rdd = sc.textFile("path/to/data")

Once an RDD is created, you can perform various actions on it, such as `reduce`, `count`, or `collect`, to yield results that can be worked with in your application.

RDD Transformations

the devops / sre roadmap diagram
the devops / sre roadmap diagram

Transformations are operations that create a new RDD based on an existing one. They are lazily evaluated, meaning they only compute when an action is encountered.

Popular transformations include `map`, `filter`, `flatMap`, and `groupByKey`. These transformations allow you to perform operations such as sorting, filtering, and aggregating data across the cluster.

PyCharm
PyCharm
DevOps Engineer Roadmap | Beginner to Advanced DevOps Learning Guide
DevOps Engineer Roadmap | Beginner to Advanced DevOps Learning Guide
Python Developer Roadmap 2026: Complete Beginner-to-Job-Ready Learning Path
Python Developer Roadmap 2026: Complete Beginner-to-Job-Ready Learning Path
Инструкция по началу работы
Инструкция по началу работы
Tool Workflow Posters: Full-Stack Developer Learning Roadmap
Tool Workflow Posters: Full-Stack Developer Learning Roadmap
R Control Structures - How to make decisions and loops in R?
R Control Structures - How to make decisions and loops in R?
Python and PyCharm installation
Python and PyCharm installation
Python Interview Prep Roadmap
Python Interview Prep Roadmap
Nelson Djalo on LinkedIn: #systemdesign #coding #interviewtips | 19 comments
Nelson Djalo on LinkedIn: #systemdesign #coding #interviewtips | 19 comments

map

The `map` transformation applies a function to each element in the RDD and returns a new RDD that contains the results. Here's an example of using `map` to square each number in an RDD:

data = [1, 2, 3, 4, 5] rdd = sc.parallelize(data) squared_rdd = rdd.map(lambda x: x ** 2)

filter

The `filter` transformation returns a new RDD containing only the elements that satisfy a given condition. Here's an example of using `filter` to keep only even numbers:

even_rdd = rdd.filter(lambda x: x % 2 == 0)

RDD Operations on a Larger Scale

Transformations like `map` and `filter` are not the only operations you can perform on RDDs. PySpark provides a rich ecosystem of higher-order functionality, such as `reduceByKey`, `groupByKey`, and `join`. These operations allow you to perform complex data processing tasks efficiently across a cluster.

reduceByKey

The `reduceByKey` transformation combines the values of duplicate keys using a custom reducer function. Here's an example of using `reduceByKey` to sum the values for each key in a key-value pair RDD:

data = [("a", 1), ("b", 2), ("a", 3), ("b", 4), ("a", 5)] rdd = sc.parallelize(data) sum_rdd = rdd.reduceByKey(lambda a, b: a + b)

join

The `join` transformation returns a new RDD that contains the intersection of two RDDs, based on a shared key. Here's an example of using `join` to combine two key-value pair RDDs:

rdd1 = sc.parallelize([("a", 1), ("b", 2)]) rdd2 = sc.parallelize([("a", 3), ("c", 4)]) joined_rdd = rdd1.join(rdd2)

By leveraging RDDs and their transformations, PySpark users can process and manipulate large datasets efficiently and effectively.

Now that you understand what RDDs are and how to use them, it's time to put this knowledge into practice and start processing your own big data with PySpark. Happy coding!