Is there a way to take the first 1000 rows of a Spark Dataframe?
Limit is very simple, example limit first 50 rows
val df_subset = data.limit(50)
The method you are looking for is .limit.
Returns a new Dataset by taking the first n rows. The difference between this function and head is that head returns an array while limit returns a new Dataset.
Example usage:
df.limit(1000)