snowflake.snowpark.functions.dense_rank¶
- snowflake.snowpark.functions.dense_rank() Column [source]¶
Returns the rank of a value within a group of values, without gaps in the ranks. The rank value starts at 1 and continues up sequentially. If two values are the same, they will have the same rank.
Example:
>>> from snowflake.snowpark.window import Window >>> window = Window.order_by("key") >>> df = session.create_dataframe([(1, "1"), (2, "2"), (1, "3"), (2, "4")], schema=["key", "value"]) >>> df.select(dense_rank().over(window).as_("dense_rank")).collect() [Row(DENSE_RANK=1), Row(DENSE_RANK=1), Row(DENSE_RANK=2), Row(DENSE_RANK=2)]