GroupBy { public DataFrame agg(Aggregator<?>... aggregators) { return DataFrameAggregation.aggGroupBy(this, aggregators); } GroupBy(DataFrame ungrouped, Map<Object, IntSeries> groupsIndex, Comparator<RowProxy> sorter); int size(); Index getUngroupedColumnIndex(); DataFrame toDataFrame(); Collection<Object> getGroups(); boolean hasGroup(Object key); IntSeries getGroupIndex(Object key); DataFrame getGroup(Object key); @Deprecated Series<Integer> rowNumbers(); IntSeries rowNumber(); IntSeries rank(); IntSeries denseRank(); Series<T> shift(String column, int offset, T filler); Series<T> shift(int column, int offset, T filler); GroupBy head(int len); GroupBy tail(int len); GroupBy sort(RowToValueMapper<V> sortKeyExtractor); GroupBy sort(Comparator<RowProxy> sorter); GroupBy sort(String column, boolean ascending); GroupBy sort(int column, boolean ascending); GroupBy sort(String[] columns, boolean[] ascending); GroupBy sort(int[] columns, boolean[] ascending); DataFrame agg(Aggregator<?>... aggregators);  }
@Test public void testGroup_Agg() { DataFrame df1 = DataFrame.newFrame("a", "b").foldByRow( 1, "x", 2, "y", 1, "z", 0, "a", 1, "x"); DataFrame df = df1.group("a").agg(Aggregator.sumLong("a"), Aggregator.concat("b", ";")); new DataFrameAsserts(df, "a", "b") .expectHeight(3) .expectRow(0, 3L, "x;z;x") .expectRow(1, 2L, "y") .expectRow(2, 0L, "a"); }
@Test public void testGroup_Agg_MultipleAggregationsForKey() { DataFrame df1 = DataFrame.newFrame("a", "b").foldByRow( 1, "x", 2, "y", 1, "y", 0, "a", 1, "x"); DataFrame df = df1 .group("b") .agg(Aggregator.first("b"), Aggregator.sumLong("a"), Aggregator.medianDouble("a")); new DataFrameAsserts(df, "b", "a", "a_") .expectHeight(3) .expectRow(0, "x", 2L, 1.) .expectRow(1, "y", 3L, 1.5) .expectRow(2, "a", 0L, 0.); }
@Test public void testGroup_Agg_Named() { DataFrame df1 = DataFrame.newFrame("a", "b").foldByRow( 1, "x", 2, "y", 1, "y", 0, "a", 1, "x"); DataFrame df = df1.group("b").agg( Aggregator.first("b"), Aggregator.sumLong("a").named("a_sum"), Aggregator.medianDouble("a").named("a_median")); new DataFrameAsserts(df, "b", "a_sum", "a_median") .expectHeight(3) .expectRow(0, "x", 2L, 1.) .expectRow(1, "y", 3L, 1.5) .expectRow(2, "a", 0L, 0.); }