Learn by fixing tests
© 2025-2026 Alex Cole. All Rights Reserved.
Spark Koans is an independent community tool.
Access previous or next row values. Replace ___ with the correct code.
___
from pyspark.sql.window import Window from pyspark.sql.functions import lag, lead, col data = [ ("2024-01-01", 100), ("2024-01-02", 150), ("2024-01-03", 120), ("2024-01-04", 200) ] df = spark.createDataFrame(data, ["date", "price"])
Output will appear here...