i am thinking to use deedle to join hundreds of series into a frame. what is the best functional way to achieve this?
The immediate (imperative) thought is to create a frame object holder outside of the loop. then within the loop this object older is used as the left hand side of the series join.
on a second thought, C#
tail recursion? i have done some research i am a bit lost as whether c# can do tail recursion. There is only F#
example from Tomas' book 'functional programming for real world'
Also has anyone had deedle frame with hundreds of columns (1000 rows)? is there a big performance impact? this may sound excessive but it is done in spreadsheet quite commonly
Any suggestion is welcome. Thank you casbby
The right approach for creating a frame depends on where your data is coming from.
If you already have all the series and you want to create a frame that contains them as columns, then the method Frame.FromColumns
is probably the way to go. The method takes a collection of key value pairs where the key is the column name and the value is the column (series).
Here is a minimal example that creates an array of key value pairs with names and series:
var cols = new KeyValuePair<string, Series<int, object>>[]{
KeyValue.Create("IDs", (new object[] {1,2,2}).ToOrdinalSeries() ),
KeyValue.Create("Namess", (new object[] {"A", "B", "C"}).ToOrdinalSeries() )
};
var frame = Frame.FromColumns(cols);
I assume that in your case, you already have the series in some collection, so the functional approach is to use LINQ and Select
to project your data into the right format. So your code might look something like:
var cols = someSource.Select(item =>
KeyValue.Create(item.Key, item.Series));
var frame = Frame.FromColumns(cols);
The FromColumns
operation is using outer join under the cover, but it is optimized (e.g. if you have series with the same index). There is a bunch of additional examples in the C# documentation for Deedle.