Featured Article

What Does RDD Do in PySpark: Understanding Core Transformations

Kenneth Jul 13, 2026

When working with big data in Python, the PySpark library is an invaluable tool that vmaps the functionality of Apache Spark to Python. One of the key functionality of PySpark is its ability to work with Resilient Distributed Datasets (RDDs), which are the fundamental data structure in Spark. So, what does RDD do in PySpark?

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

At its core, RDD is a distributed collection of elements, partitioned across the nodes of the cluster. It is immutable (once created, it cannot be changed), but can be transformed and applied to come up with new RDDs. Understanding how to manipulate RDDs is crucial in utilizing PySpark effectively, as it forms the building block for all parallel computations in Spark.

The Hitchhiker's Guide to pySpark DataFrames
The Hitchhiker's Guide to pySpark DataFrames

Transformations in RDDs

Transformations are operations that create a new RDD from an existing one. They are carried out in a lazy manner, meaning the computation is not performed until an action (a result-producing operation) is executed. This lazy evaluation feature of transformations is what makes RDDs efficient for big data processing.

an info sheet showing the different types of food
an info sheet showing the different types of food

Transformations are typically used to rearrange the data in an RDD, either by applying a function, filtering out elements, or combining elements of the RDD. Some common transformations include 'map' (applies a function to each element), 'filter' (keeps only the elements that satisfy a condition), and 'reduceByKey' (combines values of the same key).

Map

an image of a computer screen with the text code in front of it and a blue background
an image of a computer screen with the text code in front of it and a blue background

One of the most common transformations is 'map'. It takes a function and applies it to each element in the RDD. The return value of the function determines the output of the RDD. If the RDD contains integers and we apply a function that squares each number, the 'map' transformation will return a new RDD with all elements squared.

For example, the following code squares every number in an RDD:

numbers = sc.parallelize([1, 2, 3, 4])

Peptide cheat sheet ✨
Peptide cheat sheet ✨

squared_numbers = numbers.map(lambda x: x*x)

Filter

Another essential transformation is 'filter'. As its name hints, it 'filters' out elements based on a condition. This condition is given as a function, which returns a boolean value. Only elements for which this function returns 'True' are kept in the resulting RDD.

glow up tips
glow up tips

To illustrate, the following code filters out even numbers from an RDD:

numbers = sc.parallelize([1, 2, 3, 4])

CRUD Operations In Python With Source Code
CRUD Operations In Python With Source Code
Crowdfunded Projects Use Raspberry Pi and ODROID Boards into Home Theater PCs and Retro Game Consoles - CNX Software
Crowdfunded Projects Use Raspberry Pi and ODROID Boards into Home Theater PCs and Retro Game Consoles - CNX Software
Raspberry Pi Pico: Files and Directories (MicroPython) | Random Nerd Tutorials
Raspberry Pi Pico: Files and Directories (MicroPython) | Random Nerd Tutorials
Probabilistic programming library built on PyTorch
Probabilistic programming library built on PyTorch
Your body is already producing what you’re trying to replace… it just slows down with age.  Peptides are one of the most advanced ways to support: • Fat loss & metabolism • Skin rejuvenation & collagen production • Energy, recovery & longevity  I created this Peptide Cheat Sheet to simplify what actually works (because most people are overwhelmed 👀).  If you’ve been curious about: ✔️ Sermorelin ✔️ Tesamorelin ✔️ Ipamorelin ✔️ NAD+ ✔️ BPC-157  This is your starting point.  ✨ I offer access to ... Peptide Dosing Cheat Sheet, Tesamorelin Peptides, Glow Peptide Dosage Chart, Epitalon Peptide, Peptide Dosage, Tesamorelin Protocol, Peptides Cheat Sheet, Peptide Cheat Sheet, Peptides Injection Chart
Your body is already producing what you’re trying to replace… it just slows down with age. Peptides are one of the most advanced ways to support: • Fat loss & metabolism • Skin rejuvenation & collagen production • Energy, recovery & longevity I created this Peptide Cheat Sheet to simplify what actually works (because most people are overwhelmed 👀). If you’ve been curious about: ✔️ Sermorelin ✔️ Tesamorelin ✔️ Ipamorelin ✔️ NAD+ ✔️ BPC-157 This is your starting point. ✨ I offer access to ... Peptide Dosing Cheat Sheet, Tesamorelin Peptides, Glow Peptide Dosage Chart, Epitalon Peptide, Peptide Dosage, Tesamorelin Protocol, Peptides Cheat Sheet, Peptide Cheat Sheet, Peptides Injection Chart
Copper Peptides, Ghk Cu Peptide Dosage, Ghk Cu Peptide Injection, Peptides Injection Chart, Ghk Cu Peptide, Reverse Aging, Mots-c Dosing, Ghkcu Peptide Dosage Chart, Ghk Cu
Copper Peptides, Ghk Cu Peptide Dosage, Ghk Cu Peptide Injection, Peptides Injection Chart, Ghk Cu Peptide, Reverse Aging, Mots-c Dosing, Ghkcu Peptide Dosage Chart, Ghk Cu
The Ultimate Do's & Don'ts For Pimples & Clear Skin
The Ultimate Do's & Don'ts For Pimples & Clear Skin
The best peptides for research! Best prices too https://ignitepeptides.com/ref/etpe/
The best peptides for research! Best prices too https://ignitepeptides.com/ref/etpe/
Python Programming
Python Programming

even_numbers = numbers.filter(lambda x: x % 2 == 0)

Actions in RDDs

Actions are operations that trigger a computation to happen, that is, they cause Spark to execute transformations. Unlike transformations, actions typically return a value to the driver program or write it into external storage.

Common actions include 'reduce' (combines the elements of the RDD using a binary operator), 'collect' (returns all the elements of the RDD as an array), and 'saveAsTextFile' (saves the RDD's data in a text format).

Reduce

The 'reduce' action is a general way to apply a callback function to all elements of a dataset, grouped by key in the case of two arguments, like 'reduceByKey'. This function takes two arguments and returns one, so the reduction function must be associative.

The 'reduce' example below sums up all the numbers in an RDD:

numbers = sc.parallelize([1, 2, 3, 4])

sum = numbers.reduce(lambda a, b: a+b)

Collect

The 'collect' action returns a list containing all the elements from all partitions of an RDD. This is a fundamental difference between RDDs and other collection types (like lists or arrays) - RDDs represent a distributed dataset, where 'collect' triggers the computation and gathers all the data to the driver node.

While 'collect' can be useful for local data operations, using it with large RDDs should be avoided since it can lead to out of memory errors and may affect the overall performance of the cluster.

The key to effective PySpark programming is understanding how to manipulate RDDs. From there, you can extract, transform, load, and ultimately analyze big data with great efficiency and precision.