Mansi Arora
Mansi Arora

Reputation: 97

How can i create a new column in pyspark containing floating random numbers but i want to generate the same no always?

I want create a new column in spark containing floating point random numbers but i want to generate the same output always i.e i want to use a fix seed value as 102101.

Upvotes: 0

Views: 142

Answers (1)

Shubham Jain
Shubham Jain

Reputation: 5526

Try this

from pyspark.sql.functions import rand

df.withColumn('RandomNumber', rand(seed=10))

Upvotes: 1

Related Questions