Lesson 10.1 · Pro
LAG and LEAD: look at the previous or next row
Compare each row with the one before or after it, like this month vs last month.
In this lesson
- LAG gets the previous row's value
- LAG within each group
- LEAD gets the next row's value
Go Pro to read this lesson
Pro unlocks every lesson and practice problem in SQL, Python, pandas and NumPy, with answers and step-by-step explanations.