Skip to main content
PYSPARK • LESSON 33

Row Filtering with filter()

How do we isolate completed transactions from an orders dataset using Column boolean conditions?

Beginner2 Minutes170 XP
🤔 THE QUESTION

How do we isolate completed transactions from an orders dataset using Column boolean conditions?

💡 WHAT IS IT?

filter() evaluates a boolean condition on each row, keeping only records where the condition evaluates to True.

🎯 WHAT IS IT USED FOR?

Filtering data streams, isolating active entities, and discarding cancelled or inactive records.

💻 EXAMPLE
from pyspark.sql.functions import col

df.filter(col("status") == "COMPLETED").show()

🎯 Mission Objectives

Practice typing production-grade PySpark code for Row Filtering with filter().

  • Use filter() with equality check
  • Reference column with col()
  • Filter completed orders