public IEnumerable <TValue> EnumerateItems <TValue>(int[] columns, bool ascending, IEnumerable <int> rows, MultiGetterAt <TValue> getter) where TValue : ITUple, new() { var value = new TValue(); var cols = columns.ToArray(); if (cols.Length != value.Length) { throw new DataTypeError($"Dimension mismatch between {cols.Length} and {cols.Length}."); } for (int i = 0; i < Length; ++i) { getter(i, ref value); yield return(value); } }
public static DataFrameViewGroupResults <TImutKey> TGroupBy <TMutKey, TImutKey>( IDataFrameView df, int[] rows, int[] columns, IEnumerable <int> cols, bool sort, MultiGetterAt <TMutKey> getter, Func <TMutKey, TImutKey> conv, Func <TImutKey, DataFrameGroupKey[]> conv2) where TMutKey : ITUple, new() where TImutKey : IComparable <TImutKey>, IEquatable <TImutKey> { var icols = cols.ToArray(); int[] order = rows == null?rows.Select(c => c).ToArray() : Enumerable.Range(0, df.Length).ToArray(); var keys = df.EnumerateItems(icols, true, rows, getter).Select(c => conv(c)).ToArray(); if (sort) { DataFrameSorting.TSort(df, ref order, keys, true); } var iter = TGroupBy(df, order, keys, columns, conv2); return(new DataFrameViewGroupResults <TImutKey>(iter)); }
public static DataFrame TJoin <TMutKey, TImutKey>( IDataFrameView left, IDataFrameView right, int[] rowsLeft, int[] rowsRight, int[] columnsLeft, int[] columnsRight, IEnumerable <int> colsLeft, IEnumerable <int> colsRight, bool sort, string leftSuffix, string rightSuffix, JoinStrategy joinType, MultiGetterAt <TMutKey> getterLeft, MultiGetterAt <TMutKey> getterRight, Func <TMutKey, TImutKey> conv, Func <TImutKey, DataFrameGroupKey[]> convLeft, Func <TImutKey, DataFrameGroupKey[]> convRight) where TMutKey : ITUple, new() where TImutKey : IComparable <TImutKey>, IEquatable <TImutKey> { var icolsLeft = colsLeft.ToArray(); var icolsRight = colsRight.ToArray(); int[] orderLeft = rowsLeft == null?rowsLeft.Select(c => c).ToArray() : Enumerable.Range(0, left.Length).ToArray(); int[] orderRight = rowsLeft == null?rowsRight.Select(c => c).ToArray() : Enumerable.Range(0, right.Length).ToArray(); var keysLeft = left.EnumerateItems(icolsLeft, true, rowsLeft, getterLeft).Select(c => conv(c)).ToArray(); var keysRight = right.EnumerateItems(icolsRight, true, rowsRight, getterRight).Select(c => conv(c)).ToArray(); if (sort) { DataFrameSorting.TSort(left, ref orderLeft, keysLeft, true); DataFrameSorting.TSort(right, ref orderRight, keysRight, true); } var iter = TJoin <TImutKey>(left, right, orderLeft, orderRight, keysLeft, keysRight, icolsLeft, icolsRight, leftSuffix, rightSuffix, joinType, convLeft, convRight); return(DataFrame.Concat(iter)); }
public IEnumerable <TValue> EnumerateItems <TValue>(int[] columns, bool ascending, IEnumerable <int> rows, MultiGetterAt <TValue> getter) where TValue : ITUple, new() { return(_src.EnumerateItems(columns, ascending, rows == null ? _rows : rows.Select(c => _rows[c]), getter)); }