You are viewing documentation about an older version (1.16.0). View latest version

snowflake.snowpark.functions.cume_dist

snowflake.snowpark.functions.cume_dist() Column[source] (https://github.com/snowflakedb/snowpark-python/blob/v1.16.0/src/snowflake/snowpark/functions.py#L6624-L6650)

Finds the cumulative distribution of a value with regard to other values within the same window partition.

Example

>>> from snowflake.snowpark.window import Window
>>> from snowflake.snowpark.types import DecimalType
>>> df = session.create_dataframe([[1, 2], [1, 2], [1,3], [4, 5], [2, 3], [3, 4], [4, 7], [3,7], [4,5]], schema=["a", "b"])
>>> df.select(cume_dist().over(Window.order_by("a")).cast(DecimalType(scale=3)).alias("result")).show()
------------
|"RESULT"  |
------------
|0.333     |
|0.333     |
|0.333     |
|0.444     |
|0.667     |
|0.667     |
|1.000     |
|1.000     |
|1.000     |
------------
Copy
Language: English