snowflake.snowpark.functions.rank¶

snowflake.snowpark.functions.rank() → Column[source]¶

Returns the rank of a value within an ordered group of values. The rank value starts at 1 and continues up.

Example::
>>> from snowflake.snowpark.window import Window
>>> df = session.create_dataframe(
...     [
...         [1, 2, 1],
...         [1, 2, 3],
...         [2, 1, 10],
...         [2, 2, 1],
...         [2, 2, 3],
...     ],
...     schema=["x", "y", "z"]
... )
>>> df.select(rank().over(Window.partition_by(col("X")).order_by(col("Y"))).alias("result")).show()
------------
|"RESULT"  |
------------
|1         |
|2         |
|2         |
|1         |
|1         |
------------
Copy