public static Frame <K, string> FromRecords <K, R>(Series <K, R> series) { IEnumerable <Tuple <K, R> > tuples = (IEnumerable <Tuple <K, R> >) new FrameExtensions.keyValuePairs <K, R>(series, (Tuple <K, FSharpOption <R> >)null, (FSharpOption <R>)null, default(K), (IEnumerator <Tuple <K, FSharpOption <R> > >)null, 0, (Tuple <K, R>)null); Frame <int, string> frame = Reflection.convertRecordSequence <R>(SeqModule.Map <Tuple <K, R>, R>((FSharpFunc <M0, M1>) new FrameExtensions.recordsToConvert <K, R>(), (IEnumerable <M0>)tuples)); return(FrameModule.IndexRowsWith <K, int, string>((IEnumerable <K>)SeqModule.Map <Tuple <K, R>, K>((FSharpFunc <M0, M1>) new FrameExtensions.FromRecords <K, R>(), (IEnumerable <M0>)tuples), frame)); }
public static Frame <R, string> FrameReadCsvStatic <R>(string path, string indexCol, [OptionalArgument] FSharpOption <bool> hasHeaders, [OptionalArgument] FSharpOption <bool> inferTypes, [OptionalArgument] FSharpOption <int> inferRows, [OptionalArgument] FSharpOption <string> schema, [OptionalArgument] FSharpOption <string> separators, [OptionalArgument] FSharpOption <string> culture, [OptionalArgument] FSharpOption <int> maxRows, [OptionalArgument] FSharpOption <string[]> missingValues, [OptionalArgument] FSharpOption <bool> preferOptions) { StreamReader streamReader = new StreamReader(path); try { return(FrameModule.IndexRows <string, int, R>(indexCol, FrameUtilsModule.readCsv((TextReader)streamReader, hasHeaders, inferTypes, inferRows, schema, missingValues, separators, culture, maxRows, preferOptions))); } finally { (streamReader as IDisposable)?.Dispose(); } }
public static Frame <TRowKey, TColumnKey> FillMissing <TRowKey, TColumnKey, T>(this Frame <TRowKey, TColumnKey> frame, Func <Series <TRowKey, T>, TRowKey, T> f) { return(FrameModule.FillMissingUsing <TRowKey, T, TColumnKey>((FSharpFunc <Series <TRowKey, T>, FSharpFunc <TRowKey, T> >) new FrameExtensions.FillMissing2 <TRowKey, T>(f), frame)); }
public static Frame <TRowKey, TColumnKey> FillMissing <TRowKey, TColumnKey>(this Frame <TRowKey, TColumnKey> frame, Direction direction) { return(FrameModule.FillMissing <TRowKey, TColumnKey>(direction, frame)); }
public static Frame <TRowKey, TColumnKey> FillMissing <TRowKey, TColumnKey, T>(this Frame <TRowKey, TColumnKey> frame, T value) { return(FrameModule.FillMissingWith <T, TRowKey, TColumnKey>(value, frame)); }
public static Series <TRowKey2, Frame <TRowKey1, TColumnKey> > NestBy <TRowKey1, TColumnKey, TRowKey2>(this Frame <TRowKey1, TColumnKey> frame, Func <TRowKey1, TRowKey2> keyselector) { return(FrameModule.NestBy <TRowKey1, TRowKey2, TColumnKey>((FSharpFunc <TRowKey1, TRowKey2>) new FrameExtensions.NestBy <TRowKey1, TRowKey2>(keyselector), frame)); }
public static Frame <TRowKey, TColumnKey> SortRowsBy <TRowKey, TColumnKey, V, V2>(this Frame <TRowKey, TColumnKey> frame, TColumnKey key, Func <V, V2> f) { return(FrameModule.SortRowBy <TColumnKey, V, V2, TRowKey>(key, (FSharpFunc <V, V2>) new FrameExtensions.SortRowsBy <V, V2>(f), frame)); }
public static Frame <TRowKey, TColumnKey> SortRows <TRowKey, TColumnKey>(this Frame <TRowKey, TColumnKey> frame, TColumnKey key) { return(FrameModule.SortRows <TColumnKey, TRowKey>(key, frame)); }
public static Series <TColumnKey, T> Reduce <TRowKey, TColumnKey, T>(this Frame <TRowKey, TColumnKey> frame, Func <T, T, T> aggregation) { return(FrameModule.ReduceValues <T, TRowKey, TColumnKey>((FSharpFunc <T, FSharpFunc <T, T> >) new FrameExtensions.Reduce5 <T>(aggregation), frame)); }
public static Frame <TRowKey, TColumnKey> Diff <TRowKey, TColumnKey>(this Frame <TRowKey, TColumnKey> frame, int offset) { return(FrameModule.Diff <TRowKey, TColumnKey>(offset, frame)); }
public static Frame <R, C> RealignRows <R, C>(this Frame <R, C> frame, IEnumerable <R> keys) { return(FrameModule.RealignRows <R, C>(keys, frame)); }
public static Series <R, a> Window <R, C, a>(this Frame <R, C> frame, int size, Func <Frame <R, C>, a> aggregate) { return(FrameModule.WindowInto <R, C, a>(size, (FSharpFunc <Frame <R, C>, a>) new FrameExtensions.Window7 <R, C, a>(aggregate), frame)); }
public static Series <R, Frame <R, C> > Window <R, C>(this Frame <R, C> frame, int size) { return(FrameModule.Window <R, C>(size, frame)); }
public static Frame <RNew, CNew> PivotTable <R, C, RNew, CNew, T>(this Frame <R, C> frame, C r, C c, Func <Frame <R, C>, T> op) { return(FrameModule.PivotTable <R, C, RNew, CNew, T>((FSharpFunc <R, FSharpFunc <ObjectSeries <C>, RNew> >) new FrameExtensions.PivotTable7 <R, C, RNew>(r), (FSharpFunc <R, FSharpFunc <ObjectSeries <C>, CNew> >) new FrameExtensions.PivotTable7 <R, C, CNew>(c), (FSharpFunc <Frame <R, C>, T>) new FrameExtensions.PivotTable7 <R, C, T>(op), frame)); }
public static Frame <Tuple <TRowKey1, TRowKey2>, TColumnKey> Unnest <TRowKey1, TRowKey2, TColumnKey>(this Series <TRowKey1, Frame <TRowKey2, TColumnKey> > series) { return(FrameModule.Unnest <TRowKey1, TRowKey2, TColumnKey>(series)); }
public static Frame <TRowKey, TColumnKey> DropSparseColumns <TRowKey, TColumnKey>(this Frame <TRowKey, TColumnKey> frame) { return(FrameModule.DropSparseColumns <TRowKey, TColumnKey>(frame)); }
public static Frame <TRowKey, TColumnKey> SortColumnsByKey <TRowKey, TColumnKey>(this Frame <TRowKey, TColumnKey> frame) { return(FrameModule.SortColumnsByKey <TRowKey, TColumnKey>(frame)); }
public static Frame <TRowKey, TColumnKey> FilterRowsBy <TRowKey, TColumnKey, V>(this Frame <TRowKey, TColumnKey> frame, TColumnKey column, object value) { return(FrameModule.WhereRowsBy <TColumnKey, object, TRowKey>(column, value, frame)); }
public static Frame <TRowKey, TColumnKey> SortRowsWith <TRowKey, TColumnKey, V>(this Frame <TRowKey, TColumnKey> frame, TColumnKey key, Comparer <V> cmp) { return(FrameModule.SortRowsWith <TColumnKey, V, TRowKey>(key, (FSharpFunc <V, FSharpFunc <V, int> >) new FrameExtensions.SortRowsWith <V>(cmp), frame)); }
public static Frame <int, TColumnKey> IndexRowsOrdinally <TRowKey, TColumnKey>(this Frame <TRowKey, TColumnKey> frame) { return(FrameModule.IndexRowsOrdinally <TRowKey, TColumnKey>(frame)); }
public static Series <TRowKey1, Frame <TRowKey2, TColumnKey> > Nest <TRowKey1, TRowKey2, TColumnKey>(this Frame <Tuple <TRowKey1, TRowKey2>, TColumnKey> frame) { return(FrameModule.Nest <TRowKey1, TRowKey2, TColumnKey>(FrameModule.SelectRowKeys <Tuple <TRowKey1, TRowKey2>, Tuple <TRowKey1, TRowKey2>, TColumnKey>((FSharpFunc <Tuple <TRowKey1, TRowKey2>, Tuple <TRowKey1, TRowKey2> >) new FrameExtensions.Nest <TRowKey1, TRowKey2>(), frame))); }
public static Frame <R2, C> IndexRowsUsing <R, C, R2>(this Frame <R, C> frame, Func <ObjectSeries <C>, R2> f) { return(FrameModule.IndexRowsUsing <C, R2, R>((FSharpFunc <ObjectSeries <C>, R2>) new FrameExtensions.IndexRowsUsing <C, R2>(f), frame)); }
public static Frame <R, TNewRowIndex> IndexColumnsWith <R, C, TNewRowIndex>(this Frame <R, C> frame, IEnumerable <TNewRowIndex> keys) { return(FrameModule.IndexColumnsWith <TNewRowIndex, R, C>(keys, frame)); }
/// <summary> /// This code is based on the code developed by Chris Bayley /// </summary> public void Example01() { Console.WriteLine("Running Example01..."); // Systems we want to see in the chart Tuple <long, String, Color>[] systemIds = { Tuple.Create(110751645L, "Stock Growth", Color.Red), Tuple.Create(125206069L, "Marlin", Color.LightBlue), Tuple.Create(106600099L, "VIXTrader Pro", Color.LightGreen) }; // Set a preliminary Start Date DateTime StartDate = DateTime.Parse("1-feb-2008"); // Find earliest start date common to all systems foreach (var id in systemIds) { DateTime sysStartDate = (from s in C2SYSTEMS where s.SystemId == id.Item1 select s.Started).First(); if (DateTime.Compare(sysStartDate, StartDate) > 0) { StartDate = sysStartDate; } } // Get the Monthly equity data ITimeSheet timeSheet = TimeSheetFactory(systemIds.Select(id => id.Item1), TimeInterval.Month, EquityType.Equity); // =================================================================== // Here, a developer writes the exactly same code as on the web page. // =================================================================== // Say - a developer wants to play with timeSheet. // IntelliSense in action: var Developer_Trying_To_Do_Something = timeSheet.Commissions.CalcCommissions(systemIds[0].Item1); TABLE = timeSheet.GetEquitiesSheet(); //// Create a chart object //ITimeSeriesChart chart = new TimeSeriesChart(); //chart.Name = String.Format("Chris Bayley Chart"); //// Add data //foreach (Tuple<long, String, Color> system in systemIds) //{ // chart.Add(timeSheet.GetColumn(system.Item1, EquityType.Equity), system.Item2, system.Item3); //} //// Enjoy! //CHART = chart; // return the EquitySheet as a Deedle.Frame var sparseEquityFrame = timeSheet.DataFrame; // Drop the rows from the frame which dont have data for all systems var denseEquityFrame = FrameModule.DropSparseRows(sparseEquityFrame); // ??? QUESTION 1: // Now I have the data I want in denseEquityFrame and I wish to convert it to IEnumerable for display by TABLE= IEnumerable <string> rowKeyNames = new string[] { "KeyName" }; var equityDataTable = denseEquityFrame.ToDataTable(rowKeyNames); // Next line yields this error: // *** Error: Error CS0266: 139:7 Cannot implicitly convert type 'System.Data.DataTable' to // 'System.Collections.Generic.IEnumerable<object>'. An explicit conversion exists (are you missing a cast?) // If an explict conversion exits, what is it ?? //TABLE=equityDataTable; // ??? QUESTION 2: // return Equity Sheet as IEnumerable to use with TABLE= // I can do this but it includes Dates I don't want var equityTable = timeSheet.GetEquitiesSheet(); // So I'd like to do this: // equityTable = timeSheet.GetEquitiesSheet().Where(z => z.Item1 >= StartDate); // but that yields: // *** Error: Error CS1061: 146:62 'object' does not contain a definition for 'Item1' and no extension method 'Item1' // accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly reference?) TABLE = equityTable; // ============ LOCAL DEBUGGING IN VISUAL STUDIO ======== FrameExtensions.Print(denseEquityFrame); //FrameExtensions.Print(((Frame<DateTime, string>)equityTable.ElementAt(1)).GetFrameData()); FrameExtensions.Print <DateTime, string>(timeSheet.DataFrame); Console.WriteLine("Example01 done. Press ENTER"); Console.ReadLine(); }