Reducing
Pivot reducing
Each Pivot group can be collapsed into a single row and then concatenated into a new DataRow with these row values (or their derived representation) with pivot keys as top-level columns or as column groups.
Reducing is a specific case of aggregation.
First, choose a Pivot reducing method:
first,last— take the first or last row (optionally, the first or last one that satisfies a predicate) of each group;minBy/maxBy— take the row with the minimum or maximum value of the givenRowExpressionevaluated on rows within each group;medianBy/percentileBy— take the row at the position closest to the estimated median/percentile index of theRowExpression's results calculated on rows within each group.
These functions return a ReducedPivot, which can then be transformed into a new DataFrame containing a single combined row (either using the original reduced rows or their transformed versions) through one of the following methods:
values— creates a new row containing the values from the reduced rows in the selected columns and produces aDataRowof these values;with— computes a new value for each reduced row using aRowExpression, and produces aDataRowcontaining these computed values.
Each method returns a new DataRow with pivot keys as top-level columns (or as column groups) and values composed of the reduced results from each group.
Check out .Pivot grammar
For more information: See "Pivot Reducing" on the documentation website.