PivotDocs
Splits the rows of this DataFrame and groups them horizontally into new columns based on values from one or several provided columns of the original DataFrame.
Returns a Pivot — a dataframe-like structure that contains all unique combinations of key values as columns (or column groups for multiple keys) with a single row with the corresponding groups for each key combination (each represented as a DataFrame).
Works like DataFrame.groupBy but groups rows horizontally.
A Pivot can then be:
reducedinto aDataRow, where each group is collapsed into a single representative row;aggregatedinto aDataRow, where each group is transformed into a new row of derived values;groupedinto aPivotGroupBystructure, which combinespivotandgroupByoperations and then reduced or aggregated into aDataFrame.
Pivoted columns can also be created inline (i.g. by creating a new column using expr or simply renaming the old one using named):
// Create a new column "newName" based on existing "oldName" values
// and pivot it:
df.pivot { expr("newName") { oldName.drop(5) } }Check out Grammar.
This can include column groups and nested columns.
See Selecting Columns.
For more information: See pivot on the documentation website.
Types
Provides predefined shortcuts for the most common statistical aggregation operations that can be applied to each group within a Pivot.