snowflake.snowpark.functions.percent_rank¶
- snowflake.snowpark.functions.percent_rank() Column [source]¶
Returns the relative rank of a value within a group of values, specified as a percentage ranging from 0.0 to 1.0.
- 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(percent_rank().over(Window.partition_by("x").order_by(col("y"))).alias("result")).show() ------------ |"RESULT" | ------------ |0.0 | |0.5 | |0.5 | |0.0 | |0.0 | ------------