takeWhile

inline fun <T> DataFrame<T>.takeWhile(predicate: RowFilter<T>): DataFrame<T>

Returns a DataFrame containing the first rows that satisfy the given predicate.

Rows are taken for as long as the predicate holds; the operation stops at the first row that does not satisfy it, and no later row is taken even if it satisfies 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.

For more information: See takeWhile on the documentation website.

See also:

  • take — takes a fixed number of first rows.

  • takeLast — takes a fixed number of last rows.

  • dropWhile — drops the first rows while the predicate holds.

  • filter — keeps every row that matches the predicate.

Return

A DataFrame containing the first rows that satisfy the predicate.

Parameters

predicate

The RowFilter that the leading rows to take must satisfy.