Mapping
GroupBy mapping
Instead of aggregating the groups, a GroupBy can be walked over key–group pair by key–group pair, with the result of a lambda collected for each of them. Every pair is given to the lambda as a GroupWithKey, so its key values are available as key and its rows as group.
The following mapping methods are available:
map— returns aListwith one computed value per key–group pair;mapToRows— computes aDataRowper key–group pair and collects them into aDataFrame;mapToFrames— computes aDataFrameper key–group pair and collects them into aFrameColumn.
Unlike aggregation, the result is not a DataFrame with the grouping key columns: what the lambda returns is what you get. map and mapToRows leave out the pairs for which the lambda returns null, so their results can be shorter than the number of key–group pairs.
Check out .GroupBy grammar
For more information: See map on a GroupBy on the documentation website.