หมายเหตุ
การเข้าถึงหน้านี้ต้องได้รับการอนุญาต คุณสามารถลอง ลงชื่อเข้าใช้หรือเปลี่ยนไดเรกทอรีได้
การเข้าถึงหน้านี้ต้องได้รับการอนุญาต คุณสามารถลองเปลี่ยนไดเรกทอรีได้
Returns a random value with independent and identically distributed (i.i.d.) values with the specified range of numbers. The random seed is optional. The provided numbers specifying the minimum and maximum values of the range must be constant. If both of these numbers are integers, then the result will also be an integer. Otherwise if one or both of these are floating-point numbers, then the result will also be a floating-point number. Supports Spark Connect.
For the corresponding Databricks SQL function, see uniform function.
Syntax
from pyspark.databricks.sql import functions as dbf
dbf.uniform(min=<min>, max=<max>, seed=<seed>)
Parameters
| Parameter | Type | Description |
|---|---|---|
min |
pyspark.sql.Column, int, or float |
Minimum value in the range. |
max |
pyspark.sql.Column, int, or float |
Maximum value in the range. |
seed |
pyspark.sql.Column or int |
Optional random number seed to use. |
Returns
pyspark.sql.Column: The generated random number within the specified range.
Examples
from pyspark.databricks.sql import functions as dbf
spark.range(0, 10, 1, 1).select(dbf.uniform(5, 105, 3)).show() # doctest: +SKIP
+------------------+
|uniform(5, 105, 3)|
+------------------+
| 30|
| 71|
| 99|
| 77|
| 16|
| 25|
| 89|
| 80|
| 51|
| 83|
+------------------+