有没有办法获取Spark数据帧的前1000行? [英] Is there a way to take the first 1000 rows of a Spark Dataframe?
本文介绍了有没有办法获取Spark数据帧的前1000行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用randomSplit
函数来获取少量数据帧以用于开发目的,而我最终只是获取了此函数返回的第一个df.
I am using the randomSplit
function to get a small amount of a dataframe to use in dev purposes and I end up just taking the first df that is returned by this function.
val df_subset = data.randomSplit(Array(0.00000001, 0.01), seed = 12345)(0)
如果我使用df.take(1000)
,那么我最终将得到一个行数组-而不是一个数据框,因此这对我不起作用.
If I use df.take(1000)
then I end up with an array of rows- not a dataframe, so that won't work for me.
是否有更好,更简单的方法来获取df的前1000行并将其存储为另一个df?
Is there a better, simpler way to take say the first 1000 rows of the df and store it as another df?
推荐答案
查看全文