我试图用随机字符串向我的数据文件中添加一个新列,如何使randomword的输出与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))发布于 2022-05-22 06:43:09
''.join(random.choices(string.ascii_lowercase, k=N))random.choices Python 3.6+
https://stackoverflow.com/questions/72335096
复制相似问题