Dataframe
 
0.15

pivot

Edit page Last modified: 14 January 2025

Splits the rows of DataFrame and groups them horizontally into new columns based on values from one or several columns of original DataFrame.

Parameters:

  • inward — if true generated columns will be nested inside original column, otherwise they will be top-level

  • pivotColumns — columns with values for horizontal data grouping and generation of new columns

  • indexColumns — columns with values for vertical data grouping

  • defaultValue — value to fill mismatched pivot-index column pairs

  • valueColumns — columns with output values

df.pivot { city }

To pivot several columns at once you can combine them using and or then infix function:

  • and will pivot columns independently

  • then will create column hierarchy from combinations of values from pivoted columns

df.pivot { city and name.firstName }
df.pivot { city then name.firstName }