pyspark.sql.functions.
rand
Generates a random column with independent and identically distributed (i.i.d.) samples uniformly distributed in [0.0, 1.0).
New in version 1.4.0.
Changed in version 3.4.0: Supports Spark Connect.
seed value for random generator.
Column
random values.
Notes
The function is non-deterministic in general case.
Examples
>>> df = spark.range(2) >>> df.withColumn('rand', rand(seed=42) * 3).show() +---+------------------+ | id| rand| +---+------------------+ | 0|1.4385751892400076| | 1|1.7082186019706387| +---+------------------+