first
Returns the first value in this DataColumn.
For more information: See first on the documentation website.
See also firstOrNull, last, take, takeLast, single.
Return
The first value in this DataColumn.
Throws
if the DataColumn is empty.
Returns the first value in this DataColumn that matches the given predicate.
Example
// In a DataFrame of financial transactions sorted by time,
// find the amount of the first transaction over 100 euros
df.amount.first { it > 100 }For more information: See first on the documentation website.
See also firstOrNull, last, take, takeLast, single.
Return
The first value in this DataColumn that matches the given 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.
Throws
if the DataColumn contains no elements matching the predicate (including the case when the DataColumn is empty).
Returns the first row in this DataFrame.
For more information: See first on the documentation website.
See also firstOrNull, last, take, takeWhile, takeLast, single, that fails unless there is exactly one row to return.
Return
Throws
if the DataFrame contains no rows.
Returns the first row in this DataFrame that satisfies the given 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 sorted by time,
// find the first transaction with amount over 100 euros
df.first { amount > 100 }For more information: See first on the documentation website.
See also firstOrNull, last, take, takeWhile, takeLast, single, that fails unless there is exactly one row to return.
Return
A DataRow containing the first row that matches the given predicate.
Parameters
A row filter used to get the first value that satisfies a condition specified in this filter.
Throws
Reduces the groups of this GroupBy by taking the first row from each group, and returns a ReducedGroupBy containing these rows (one row per group, each row is the first row in its group).
If a group in this GroupBy is empty, the corresponding row in the resulting ReducedGroupBy will contain null values for all columns in the group, except the grouping key.
Example
// In a DataFrame of orders sorted by date and time,
// find the first order placed by each customer
df.groupBy { customerId }.first().concat()For more information: See first on the documentation website.
For more information about GroupBy and first with examples: See groupBy on the documentation website.
See also last.
Return
A ReducedGroupBy containing the first row (or a row with null values, except the grouping key) from each group.
Reduces the groups of this GroupBy by taking from each group the first row satisfying the given predicate, and returns a ReducedGroupBy containing these rows (one row per group, each row is the first row in its group that satisfies the predicate).
If the group in GroupBy contains no matching rows, the corresponding row in ReducedGroupBy will contain null values for all columns in the group, except the grouping key.
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 orders sorted by date and time,
// find the first order over 100 euros placed by each customer
df.groupBy { customerId }.first { total > 100 }.concat()For more information: See first on the documentation website.
For more information about GroupBy and first with examples: See groupBy on the documentation website.
See also last.
Return
A ReducedGroupBy containing the first row matching the predicate (or a row with null values, except the grouping key) from each group.
Parameters
A row filter used to get the first value that satisfies a condition specified in this filter.
Reduces this Pivot by taking the first row from each group, and returns a ReducedPivot that contains the first row from the corresponding group in each column.
For more information: See first on the documentation website.
For more information about Pivot and first with examples: See pivot on the documentation website.
Example
// In a DataFrame of real estate listings sorted by price,
// find the cheapest listing for each type of property (house, apartment, etc.)
df.pivot { type }.first().values()Return
A ReducedPivot containing in each column the first row from the corresponding group.
Reduces this Pivot by taking from each group the first row satisfying the given predicate, and returns a ReducedPivot that contains the first row, matching the predicate, from the corresponding group in each column.
For more information: See first on the documentation website.
For more information about Pivot and first with examples: See pivot on the documentation website.
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 real estate listings sorted by price,
// find the cheapest listing for each type of property (house, apartment, etc.)
// with is not yet sold out.
df.pivot { type }.first { !soldOut }.values()Return
A ReducedPivot containing in each column the first row that satisfies the predicate, from the corresponding group (or a row with null values).
Parameters
A row filter used to get the first value that satisfies a condition specified in this filter.
Reduces this PivotGroupBy by taking the first row from each combined pivot + groupBy group, and returns a ReducedPivotGroupBy that contains the first row from each corresponding group. If any combined pivot + groupBy group in PivotGroupBy is empty, in the resulting ReducedPivotGroupBy it will be represented by a row with null values (except the grouping key).
For more information: See first on the documentation website.
For more information about PivotGroupBy with examples: See "pivot + groupBy" on the documentation website.
Example
// In a DataFrame of real estate listings sorted by price,
// find the cheapest listing for each combination of type of property (house, apartment, etc.)
// and the city it is located in
df.pivot { type }.groupBy { city }.first().values()See also groupBy, pivot, reduce, last.
Return
A ReducedPivotGroupBy containing in each combination of a groupBy key and a pivot key either the first row of the corresponding DataFrame formed by this pivot–group pair, or a row with null values (except the grouping key) if this DataFrame is empty.
Reduces this PivotGroupBy by taking from each combined pivot + groupBy group the first row satisfying the given predicate. Returns a ReducedPivotGroupBy that contains the first row, matching the predicate, from each corresponding group. If any combined pivot + groupBy group in PivotGroupBy does not contain any rows matching the predicate, in the resulting ReducedPivotGroupBy it will be represented by a row with null values (except the grouping key).
For more information: See first on the documentation website.
See "pivot + groupBy" on the documentation website.
See pivot on the documentation website.
See groupBy on the documentation website.
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 real estate listings sorted by price,
// for each combination of type of property (house, apartment, etc.)
// and the city it is located in,
// find the cheapest listing that is not yet sold out
df.pivot { type }.groupBy { city }.first { !soldOut }.values()See also groupBy, pivot, reduce, last.
Return
A ReducedPivotGroupBy containing in each combination of a groupBy key and a pivot key either the first matching the predicate row of the corresponding DataFrame formed by this pivot–group pair, or a row with null values if this DataFrame does not contain any rows matching the predicate.
Parameters
A row filter used to get the first value that satisfies a condition specified in this filter.