Spark 2 Workbook Answers May 2026

## 8. Final Checklist Before Submitting

print(f"Unique words: unique_word_count") spark 2 workbook answers

words = lines.flatMap(lambda line: line.split()) # optional cleaning cleaned = words.map(lambda w: w.lower().strip('.,!?"\'')) distinct_words = cleaned.distinct() count = distinct_words.count() spark 2 workbook answers

val spark = SparkSession.builder() .appName("DeptSalary") .getOrCreate() spark 2 workbook answers

# 1️⃣ Load the file as an RDD lines = sc.textFile("hdfs:///data/input.txt")

# 2️⃣ Split lines into words and clean them words = lines.flatMap(lambda line: line.split()) \ .map(lambda w: w.lower().strip('.,!?"\''))

Leave a Reply