Transformation
GroupBy transformations
A GroupBy can be transformed into a new GroupBy using one of the following methods:
sortByGroup/sortByGroupDesc— sorts the order of groups (and their corresponding keys) by values computed with aDataFrameExpressionapplied to each group;sortByCount/sortByCountAsc— sorts the order of groups (and their corresponding keys) by the number of rows they contain;sortByKey/sortByKeyDesc— sorts the order of groups (and their corresponding keys) by the grouping key values;sortBy/sortByDesc— sorts the order of rows within each group by one or more column values;updateGroups— transforms each group into a new one;filter— filters out keys and corresponding groups that do not satisfy the given key-group predicate;add— adds a new column to each group.
Each method returns a new GroupBy with updated group order or modified group content.
Check out .GroupBy grammar
For more information: See "GroupBy Transformation" on the documentation website.