我尝试使用这段代码。
from pyspark.sql.functions import rand,when
df1 = df.withColumn('isVal', when(rand()0.5,1).otherwise(0.6))
但是这段代码只能生成整数,我想要生成1.5到2.5之间的数字,我该如何在Pyspark中实现?