0

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

Marcela Bejarano
  • 103
  • 1
  • 1
  • 7

1 Answers1

0

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!

love2phish
  • 229
  • 1
  • 4
  • 13