0
我试图获取Pyspark中的数据框中列的不同值,并将它们保存在列表中,此时列表中包含“Row(no_children = 0)“ 但我只需要该值,因为我将其用于我的代码的另一部分。将Pyspark中的Dataframe中的不同值转换为列表
所以,最好只all_values = [0,1,2,3,4]
all_values=sorted(list(df1.select('no_children').distinct().collect()))
all_values
[Row(no_children=0),
Row(no_children=1),
Row(no_children=2),
Row(no_children=3),
Row(no_children=4)]
这需要大约15secs来运行,是正常的吗?
非常感谢!
好极了,这个选项是更快。虽然命令行输出WARN TaskSetManager:阶段849包含一个非常大的任务(165 KB)。建议的最大任务大小为100 KB。 – Learner
这通常发生在从驱动程序传输到执行程序或由于数据分区导致的巨大列表中。请检查此,https://stackoverflow.com/questions/28878654/spark-using-python-how-to-resolve-stage-x-contains-a-task-of-very-large-size-x – Suresh
反正,希望这个答案帮助你。如果你没有问题,你能接受吗? – Suresh