A minor correction to the previous answer:
data = data.withColumn("random_num", round(rand()*30+0.5).cast("int"))
This adds 0.5 so that we don't get 0 as one of the outcomes, and casts the result to an integer.