def test_aggregate_count(self, use_numba): if use_numba and not dataiter.USE_NUMBA: pytest.skip("No Numba") with patch("dataiter.USE_NUMBA", use_numba): data = DataFrame(g=GROUPS) stat = data.group_by("g").aggregate(n=count()) assert (stat.n == 2).all()
def test_aggregate(self, function, input, output, use_numba): if use_numba and not dataiter.USE_NUMBA: pytest.skip("No Numba") with patch("dataiter.USE_NUMBA", use_numba): data = DataFrame(g=GROUPS, a=input) stat = data.group_by("g").aggregate(a=function("a")) expected = Vector(output) try: assert stat.a.equal(expected) except AssertionError: print("") print(data) print("Expected:") print(expected) print("Got:") print(stat.a) raise
def test_modify_group_wise(self): data = DataFrame(g=[1, 2, 2, 3, 3, 3]) data = data.group_by("g").modify(f=lambda x: 1 / x.nrow) assert data.f.tolist() == [1, 1 / 2, 1 / 2, 1 / 3, 1 / 3, 1 / 3]