pivot(columnToPivot, func = gdf => gdf.count()) {
        const columns = [
            ...this.on,
            ...this.df.distinct(columnToPivot).toArray(columnToPivot)
        ];
        return this.df.__newInstance__(
            this.aggregate(group =>
                group
                    .groupBy(columnToPivot)
                    .aggregate((gp, gk) => ({
                        [gk[columnToPivot]]: func(gp, gk)
                    }))
                    .toArray("aggregation")
                    .reduce(
                        (p, n) => ({
                            ...p,
                            ...n
                        }),
                        {}
                    )
            )
                .toCollection()
                .map(({ aggregation, ...rest }) => ({
                    ...rest,
                    ...aggregation
                })),
            columns
        );
    }
Pivot a GroupedDataFrame.
@param {String} columnToPivot The column which will be transposed as columns.
@param {Function} [func=(gdf) => gdf.count()] The function to define each column value from a DataFrame.
@returns {DataFrame} The pivot DataFrame.
@example
df.groupBy('carType').pivot('carModel', values => values.stat.sum('kms'))