Learn by fixing tests
© 2025-2026 Alex Cole. All Rights Reserved.
Spark Koans is an independent community tool.
Assign sequential row numbers within groups. Replace ___ with the correct code.
___ blanks in the code editor with the correct PySpark code, then hit Run Code. Stuck? Try the Hint button.from pyspark.sql.window import Window
from pyspark.sql.functions import row_number, col
data = [
("Sales", "Alice", 5000),
("Sales", "Bob", 5500),
("Engineering", "Charlie", 6000),
("Engineering", "Diana", 6500),
("Engineering", "Eve", 5500)
]
df = spark.createDataFrame(data, ["dept", "name", "salary"])Output will appear here...