Reputation: 57
FrameExtensions appears to support sorting by only a single column. OrderBy had a ".ThenBy" option, but that appears to be deprecated. Any other way to sort by "DATE" then by "RECN"?
Code:
using System;
using Deedle;
namespace test
{
class MainClass
{
public static void Main (string[] args)
{
var df1 = Frame.ReadCsv (@"../../test.csv");
Console.WriteLine(df1.GetType ());
df1.Print ();
FrameExtensions.SortRows (df1, "DATE").Print();
}
}
}
This doesn't work, either:
df1.GroupRowsBy<int> ("RECN").GroupRowsBy<DateTime> ("DATE").Print ();
df1.GroupRowsBy<DateTime> ("DATE").GroupRowsBy<int> ("RECN").Print ();
Data:
NAME,TYPE,DATE,RECN,COMM
Kermit,Frog,06/30/14,1,1test
Kermit,Frog,06/30/14,1,2test
Ms. Piggy,Pig,07/01/14,2,1test
Fozzy,Bear,06/29/14,3,1test
Kermit,Frog,07/02/14,1,3test
Kermit,Frog,07/02/14,1,4test
Kermit,Frog,07/02/14,1,5test
Ms. Piggy,Pig,07/02/14,2,3test
Fozzy,Bear,07/02/14,3,2test
Ms. Piggy,Pig,07/02/14,2,2test
Upvotes: 1
Views: 455
Reputation: 5138
Assuming FrameExtensions.SortRows
is stable, you could just sort each column in reverse order of their sort priority.
For example if you want to sort by "DATE" and then by "RECN", sort first by "RECN" and then sort the result by "DATE".
This is based on how Radix Sort works.
Upvotes: 1