[ Web Proxy ]
URL:
Viewing: https://spark.apache.org/docs/latest/api/python/reference/api/../api/pyspark.RDD.first.html [Back]  [Original]

pyspark.RDD.first — PySpark 4.2.0 documentation Skip to main content
Search the docs ...:

pyspark.RDD.first#

RDD.first()[source]#

Return the first element in this RDD.

New in version 0.7.0.

Returns
T

the first element

Examples

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

Web Proxy Viewer  |  New URL  |  Original Page