Sample code for tabulardata functions

Can anyone show me some sample codes of the following function?

func aggregated<Element, Result>( on columnNames: [String], naming: (String) -> String, transform: (DiscontiguousColumnSlice<Element>) throws -> Result? ) rethrows -> DataFrame

Replies

Here is an example that computes the mean of the speed and weight columns using this method:

let means = dataFrame.grouped(by: "species").aggregated(
    on: "speed", "weight",
    naming: { "mean(\($0))" },
    transform: { (slice: DiscontiguousColumnSlice<Double>) -> Double? in
        slice.mean()
    }
)