firstOrNull
Returns the first value in this DataColumn. If the DataColumn is empty, returns null.
For more information: See firstOrNull on the documentation website.
See also first, last, take, takeLast, single.
Return
The first value in this DataColumn, or null if the DataColumn is empty.
Returns the first value in this DataColumn that matches the given predicate. Returns null if the DataColumn contains no elements matching the predicate (including the case when the DataColumn is empty).
Example
// In a DataFrame of financial transactions sorted by time,
// find the amount of the first transaction over 100 euros,
// or 'null' if there is no such transaction
df.amount.firstOrNull { it > 100 }For more information: See firstOrNull on the documentation website.
See also first, last, take, takeLast, single.
Return
The first value in this DataColumn that matches the given predicate, or null if the DataColumn contains no elements matching the predicate.
Parameters
A lambda expression used to get the first value that satisfies a condition specified in this expression. This predicate takes a value from the DataColumn as an input and returns true if the value satisfies the condition or false otherwise.
Returns the first row in this DataFrame. If the DataFrame does not contain any rows, returns null.
For more information: See firstOrNull on the documentation website.
See also first, last, take, takeWhile, takeLast, singleOrNull, that returns null unless there is exactly one row to return.
Return
A DataRow containing the first row in this DataFrame, or null if the DataFrame is empty.
Returns the first 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).
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 sorted by time,
// find the first transaction with amount over 100 euros,
// or 'null' if there is no such transaction
df.firstOrNull { amount > 100 }For more information: See firstOrNull on the documentation website.
See also first, last, take, takeWhile, takeLast, singleOrNull, that returns null unless there is exactly one row to return.
Return
A DataRow containing the first row that matches the given predicate, or null if the DataFrame contains no rows matching the predicate.
Parameters
A row filter used to get the first value that satisfies a condition specified in this filter.