Skip to content

Commit

Permalink
GroupBy.rowNumber() #16
Browse files Browse the repository at this point in the history
* making sure this doesnt blow up on an emty DataFrame
  • Loading branch information
andrus committed Jul 11, 2019
1 parent e904831 commit d0a3b75
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions dflib/src/main/java/com/nhl/dflib/GroupBy.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ public DataFrame getGroup(Object key) {
*/
public Series<Integer> rowNumbers() {

if(groupsIndex.size() == 0) {
return IntSeries.forInts();
}

DataFrame[] numberedIndex = new DataFrame[groupsIndex.size()];

int i = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@

public class DataFrame_GroupBy_WindowFuncsTest {

@Test
public void testGroupBy_RowNumbers_Emtpy() {
DataFrame df = DataFrame.newFrame("a", "b", "c").empty();
Series<Integer> rn = df.group("a").rowNumbers();
new SeriesAsserts(rn).expectData();
}

@Test
public void testGroupBy_RowNumbers0() {
DataFrame df = DataFrame.newFrame("a", "b", "c").foldByRow(
Expand Down

0 comments on commit d0a3b75

Please sign in to comment.