I am trying to add a new column to my dataframe with random strings, how do I conform the output of randomword to input of withColumn
def randomword(length):
letters = string.ascii_lowercase
return ''.join(random.choice(letters) for i in range(length))
df_with_new_col = mydf.withColumn('random_string', randomword(10))