pyspark.RDD.first

RDD.first() → T

Return the first element in this RDD.

Examples

>>> sc.parallelize([2, 3, 4]).first()
2
>>> sc.parallelize([]).first()
Traceback (most recent call last):
    ...
ValueError: RDD is empty