更新时间:2023-11-18 20:03:58
您可以先使用 rand()
函数进行随机排序:
You can order in random order using rand()
function first:
df.select('id').orderBy(rand()).limit(3).collect()
有关 rand()
函数的更多信息,请查看 pyspark.sql.functions.rand.
For more information on rand()
function, check out pyspark.sql.functions.rand.