Dataframe
 
1.0

pivot

Edit pageLast modified: 05 June 2025

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

See column selectors for how to select the columns for this operation.

Parameters:

  • inward — if true generated columns are nested inside the 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 }