DataFrame 1.0 Help

single

Returns the single row in this DataFrame. Throws NoSuchElementException if the DataFrame is empty, and IllegalArgumentException if it has more than one row.

The examples on this page use the following DataFrame:

df
df .filter { age == 45 } // one row is left after filtering .single()
df .filter { "age"<Int>() == 45 } // one row is left after filtering .single()

If a condition is specified, returns the single row that matches it, and throws an exception if there is no matching row or if there is more than one.

df.single { age == 45 } // only Bob Dylan is 45
df.single { "age"<Int>() == 45 } // only Bob Dylan is 45

singleOrNull

Returns the single row in this DataFrame, or null if the DataFrame is empty or has more than one row.

val noOne = df .filter { age > 50 } // df is empty after filtering .singleOrNull() // returns null
val noOne = df .filter { "age"<Int>() > 50 } // df is empty after filtering .singleOrNull() // returns null

If a condition is specified, returns the single row that matches it, or null if there is no matching row or if there is more than one.

val noOne = df.singleOrNull { age == 30 } // returns null: three people are 30
val noOne = df.singleOrNull { "age"<Int>() == 30 } // returns null: three people are 30
29 September 2026