pyspark.sql.functions.lead

pyspark.sql.functions.lead(col: ColumnOrName, offset: int = 1, default: Optional[Any] = None) → pyspark.sql.column.Column[source]

Window function: returns the value that is offset rows after the current row, and default if there is less than offset rows after the current row. For example, an offset of one will return the next row at any given point in the window partition.

This is equivalent to the LEAD function in SQL.

New in version 1.4.0.

Parameters
colColumn or str

name of column or expression

offsetint, optional

number of row to extend

defaultoptional

default value