Window functions

A window function computes a value for each row from a group of related rows, without collapsing them into one: rank, running total, previous value. It is defined with a partitioning (partitionBy), an ordering (orderBy), and optionally a row frame.

Example

w = Window.partitionBy('client').orderBy('date')
df.withColumn('rang', F.row_number().over(w))

Related concepts

The whole glossary