I am trying to figure what is the best way in F# to create a Deedle Frame, when the data comes from an SQL server. I have tried things like the following.
#I "../packages/Deedle.0.9.12"
#load "Deedle.fsx"
#r "System.dll"
#r "System.Data.dll"
#r "System.Data.Linq"
#r "FSharp.Data.TypeProviders.dll"
open System
open System.Data
open System.Data.Linq
open Microsoft.FSharp.Data.TypeProviders
open Deedle
type dbSchema = SqlDataConnection<"Data Source=server;Initial Catalog=database;Integrated Security=SSPI;">
let db = dbSchema.GetDataContext()
let fr = db.SomeTable |> Frame.ofRows
and a few other variants. But without luck. I am new to both F# and Deedle for that matter. I can see why the above does not work (the Frame.ofRows is not compatible with the argument) but I don't know what is the best way to proceed (or even how to proceed).
The
Frame.ofRows
function expects a sequence of series that represent individual rows of the frame. Similarly toFrame.ofColumns
, this function is useful if you already have some series objects (or if you are creating everything from scratch). They take input of typeseq<'TRowKey * ISeries<'TColKey>>
.When you're creating Deedle frame from some .NET data structure, you can use
Frame.ofRecords
which will work on any sequence and it will use reflection to get the names of the properties (and treat them as column names).A long explanation, but just a few characters change in your code :-). I tested it with Northwind:
The result is: