I want to generate a column with random numbers like this:
df=df.withColumn("random_col",random.randint(100000, 1000000))
The above gives me an error:
AssertionError: col should be Column
I want to generate a column with random numbers like this:
df=df.withColumn("random_col",random.randint(100000, 1000000))
The above gives me an error:
AssertionError: col should be Column
First I would make sure you have imported the correct stuff...
Try importing: from pyspark.sql.functions import rand
And then trying something like this line of code:
df1 = df.withColumn("random_col", rand() > 100000, 1000000)
You also could check out this resource. It looks like it may be helpful for what you are doing
Hope this helps!