How to do groupby and then sort the groups?

User 1014 | 12/20/2014, 2:17:49 AM

In GraphLab do we have an equivalent of 'order by' that can be used along with 'group by' -- similar to what we have in SQL? I'd like to be able to apply groupby to an sframe and then do a sort within each group.

Thanks, Cirrus


User 18 | 12/21/2014, 4:37:17 AM

There's no orderby aggregator for groupby. The closest thing to what you're asking for would be to sort on both the groupby column and the orderby column. SFrame.sort() takes in a list of column names. So you can do something like

<pre> sortedsf = origsf.sort(['groupbycolumnname', 'orderbycolumnname']) </pre>

See the <a href="">API doc</a> for more info.