lastOrNull

Returns the last value in this DataColumn. If the DataColumn is empty, returns null.

For more information: See lastOrNull on the documentation website.

See also last, first, take, takeLast, single.

Return

The last value in this DataColumn, or null if the DataColumn is empty.


inline fun <T> DataColumn<T>.lastOrNull(predicate: (T) -> Boolean): T?

Returns the last 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 most recent financial transaction over 100 euros,
// or 'null' if there is no such transaction
df.amount.lastOrNull { it > 100 }

For more information: See lastOrNull on the documentation website.

See also last, first, take, takeLast, single.

Return

The last value in this DataColumn that matches the given predicate, or null if the DataColumn contains no elements matching the predicate.

Parameters

predicate

A lambda expression used to get the last 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.


inline fun <T> DataFrame<T>.lastOrNull(predicate: RowFilter<T>): DataRow<T>?

Returns the last 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,
// obtain the most recent financial transaction with amount over 100 euros,
// or 'null' if there is no such transaction
df.lastOrNull { amount > 100 }

For more information: See lastOrNull on the documentation website.

See also last, first, take, takeLast, takeWhile, singleOrNull, that returns null unless there is exactly one row to return.

Return

A DataRow containing the last row that matches the given predicate, or null if the DataFrame contains no rows matching the predicate.

Parameters

predicate

A row filter used to get the last value that satisfies a condition specified in this filter.


Returns the last row in this DataFrame. If the DataFrame does not contain any rows, returns null.

For more information: See lastOrNull on the documentation website.

See also last, first, take, takeLast, singleOrNull, that returns null unless there is exactly one row to return.

Return

A DataRow containing the last row in this DataFrame, or null if the DataFrame is empty.