หมายเหตุ
การเข้าถึงหน้านี้ต้องได้รับการอนุญาต คุณสามารถลอง ลงชื่อเข้าใช้หรือเปลี่ยนไดเรกทอรีได้
การเข้าถึงหน้านี้ต้องได้รับการอนุญาต คุณสามารถลองเปลี่ยนไดเรกทอรีได้
Generates a random column with independent and identically distributed (i.i.d.) samples from the standard normal distribution. Supports Spark Connect.
For the corresponding Databricks SQL function, see randn function.
Syntax
from pyspark.databricks.sql import functions as dbf
dbf.randn(seed=<seed>)
Parameters
| Parameter | Type | Description |
|---|---|---|
seed |
int (default: None) |
Seed value for the random generator. |
Returns
pyspark.sql.Column: A column of random values.
Examples
from pyspark.databricks.sql import functions as dbf
spark.range(0, 2, 1, 1).select("*", dbf.randn()).show() # doctest: +SKIP
+---+--------------------------+
| id|randn(3968742514375399317)|
+---+--------------------------+
| 0| -0.47968645355788...|
| 1| -0.4950952457305...|
+---+--------------------------+
from pyspark.databricks.sql import functions as dbf
spark.range(0, 2, 1, 1).select("*", dbf.randn(seed=42)).show() # doctest: +SKIP
+---+------------------+
| id| randn(42)|
+---+------------------+
| 0| 2.384479054241...|
| 1|0.1920934041293...|
+---+------------------+