Skip to main content

first (DataFrame)

Returns the first row as a Row.

Syntax

first()

Returns

Row: First row if DataFrame is not empty, otherwise None.

Examples

Python
df = spark.createDataFrame([
(2, "Alice"), (5, "Bob")], schema=["age", "name"])
df.first()
# Row(age=2, name='Alice')