singleOrNull
Returns the single row in this DataFrame. Returns null if the DataFrame contains no rows or contains more than one row.
For more information: See singleOrNull on the documentation website.
See also single, that throws instead of returning null, and firstOrNull, lastOrNull, that return the first or the last row, or null if the DataFrame is empty, and do not require the DataFrame to contain exactly one row.
Return
A DataRow containing the single row in this DataFrame, or null if the DataFrame contains no rows or contains more than one row.
Returns the single row in this DataFrame that satisfies the given predicate. Returns null if the DataFrame contains no rows matching the predicate (including the case when the DataFrame is empty) or contains more than one row matching the predicate.
The predicate is a RowFilter — a lambda that receives each DataRow as both this and it and is expected to return a Boolean value.
It allows you to define conditions using the row's values directly, including through extension properties for convenient and type-safe access.
For more information, See RowFilter on the documentation website.
This can include column groups and nested columns.
Example
// In a DataFrame of financial transactions,
// find the only transaction made with the given id,
// or 'null' if there is no such transaction or there is more than one
df.singleOrNull { id == 137 }For more information: See singleOrNull on the documentation website.
See also single, that throws instead of returning null, and firstOrNull, lastOrNull, that return the first or the last matching row, or null if there is none, and do not require the DataFrame to contain exactly one matching row.
Return
A DataRow containing the single row that matches the given predicate, or null if there is no such row or there is more than one.
Parameters
A row filter used to get the single row that satisfies a condition specified in this filter.