The HR department needs a quick report identifying all high-earning employees in the organization who earn more than $80,000 annually. You must extract only their names and departments.
The processing pipeline will ingest the following local mock file structures (e.g. simulated as `dataset.csv`):
| id | name | department | salary | active |
|---|---|---|---|---|
| 1 | Alice | Engineering | 120000 | true |
| 2 | Bob | Marketing | 90000 | true |
| 3 | Charlie | Sales | 75000 | true |
| 4 | David | Engineering | 85000 | true |
| 5 | Eve | Marketing | 78000 | true |
id,name,department,salary,active 1,Alice,Engineering,120000,true 2,Bob,Marketing,90000,true 3,Charlie,Sales,75000,true 4,David,Engineering,85000,true 5,Eve,Marketing,78000,true
Copy this starter template to write the data transformation logic:
# starter.py - Employee Data Filtering
from pyspark.sql import SparkSession
from pyspark.sql.functions import col
def filter_employees():
spark = SparkSession.builder.appName("EmployeeFilter").getOrCreate()
# TODO: Read dataset.csv
# TODO: Filter salaries > 80000 and select name, department
pass
if __name__ == "__main__":
filter_employees()spark.read.csv specifying header=True and inferSchema=True. This tells Spark to parse the first line as column names and detect numeric fields automatically.
col("salary") > 80000 to filter out rows containing lower-paid employees.
name and department columns to match HR's reporting layout.
show() to print the final DataFrame rows to stdout.