forEach
Calls action for every value of this DataColumn, from the first one to the last one.
This function returns Unit, so it is only useful for its side effects, such as printing values or collecting them. To get a new DataColumn of computed values instead, use map.
For more information: See forEach on a DataColumn on the documentation website.
See also forEachIndexed — the same, and the position of every value is given as well.
Example
// Prints the ages, from the first value to the last one:
// 15, 45, 20, 40, 30, 20, 30
df.age.forEach { println(it) }Parameters
A function that is called with every value of this column.
Calls action for every row of this DataFrame, from the first one to the last one.
action gets the row both as its receiver and as its argument, so inside it age and it.age mean the same thing.
This function returns Unit, so it is only useful for its side effects, such as printing values or collecting them. To get a List of computed values instead, use map.
For more information: See iterating on the documentation website. See Row Expressions on the documentation website.
See also:
forEach— goes over the values of a single column.mapToColumn— computes a value for every row and collects the results into aDataColumn.mapToFrame— computes several columns at once and returns them as a newDataFrame.
Example
// Prints the age of every person, from the first row to the last one
df.forEach { println(it.age) }Parameters
A RowExpression that is called with every row of this DataFrame.
Calls body for every key–group pair of this GroupBy, in the order in which the pairs appear in it.
body gets each pair as a GroupBy.Entry: its key is the row of keys with the key values, and its group is a DataFrame with the rows of that group. The entry can be destructured, as (key, group).
This function returns Unit, so it is only useful for its side effects, such as printing values or collecting them. To get a List of computed values instead, use map.
For more information: See forEach on a GroupBy on the documentation website.
See also forEach — goes over the rows of a DataFrame.
Example
// Prints the number of people per city:
// "London: 1", "Dubai: 1", "Moscow: 2", ...
df.groupBy { city }.forEach { (key, group) ->
println("${key.city}: ${group.rowsCount()}")
}Parameters
A function that is called with every key–group pair of this GroupBy.