コード例 #1
0
 public void TSort <T1, T2, T3>(IEnumerable <int> columns, bool ascending = true)
     where T1 : IEquatable <T1>, IComparable <T1>
     where T2 : IEquatable <T2>, IComparable <T2>
     where T3 : IEquatable <T3>, IComparable <T3>
 {
     DataFrameSorting.TSort <T1, T2, T3>(this, ref _rows, columns, ascending);
 }
コード例 #2
0
        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));
        }
コード例 #3
0
        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));
        }
コード例 #4
0
 /// <summary>
 /// Sorts rows.
 /// </summary>
 public void Sort(IEnumerable <int> columns, bool ascending = true)
 {
     DataFrameSorting.Sort(this, columns, ascending);
 }
コード例 #5
0
 /// <summary>
 /// Sorts rows.
 /// </summary>
 public void Sort(IEnumerable <string> columns, bool ascending = true)
 {
     DataFrameSorting.Sort(this, columns.Select(c => GetColumnIndex(c)), ascending);
 }