BlueMountainCapital/Deedle — pull request #149 by adamklein (2014-02-10 23:53:38+00:00)
Title: #142 alternate take, keeping semantics same

This is an alternate way to speed up #142. It's about 20% slower than the GH142 branch PR, because nest and groupby are two separate operations ...

open Deedle
open System

let genRandomNumbers count =
let rnd = System.Random()
List.init count (fun _ -> (float <| rnd.Next()) / (float Int32.MaxValue))

let r = genRandomNumbers 1000000
let x = [for i in r -> if i > 0.5 then "x" else "y" ]
let s = Series.ofValues(x)
let n = Series.ofValues(r)
let f = Frame.ofColumns ["s" => s]
f?n <- n

let means = f.GroupRowsBy("s") |> Frame.nest |> Series.mapValues (fun df -> df?n |> Series.mean)