how to use groupby method ?
Closed this issue · 2 comments
mullerhai commented
HI ,when I create the Frame[Int,int,string] by saddle ,I want to compute one field column every element count, like
frame.columnAt(index).groupby( ele => ele.count), but I found can not coding like this, how to do it,thanks
mullerhai commented
also I can use origin scala method like this
val dataCsvOpt =csv.CsvParser.parseFromIterator[String](charBufferIter,fieldSeparator='\t',recordSeparator = "\n").toOption
val dataCsv = dataCsvOpt.get._1
val maiArr= dataCsv.colAt(27).values.map(el =>(el,1)).toArray.groupBy(el =>el._1).mapValues(el => el.map(_._2).sum).toList.sortBy(_._2).reverse
pityka commented
Hi, sorry for the late answer.
Frame's groupby always operates on row index.
However you can provide a custom index for the group by https://pityka.github.io/saddle/api/org/saddle/Frame.html#groupBy[Y](fn:RX=%3EY)(implicitevidence$35:org.saddle.ST[Y],implicitevidence$36:org.saddle.ORD[Y]):org.saddle.groupby.FrameGrouper[Y,RX,CX,T]