Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
mrocklin committed Feb 28, 2019
1 parent 0101feb commit 51a25ab
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 20 deletions.
3 changes: 2 additions & 1 deletion dask/dataframe/groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -937,7 +937,8 @@ def count(self, split_every=None, split_out=1):
def mean(self, split_every=None, split_out=1):
s = self.sum(split_every=split_every, split_out=split_out)
c = self.count(split_every=split_every, split_out=split_out)
c = c[s.columns]
if is_dataframe_like(s):
c = c[s.columns]
return s / c

@derived_from(pd.core.groupby.GroupBy)
Expand Down
19 changes: 0 additions & 19 deletions dask/dataframe/tests/test_dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -3410,22 +3410,3 @@ def test_meta_error_message():
assert 'Series' in str(info.value)
assert 'DataFrame' in str(info.value)
assert 'pandas' in str(info.value)


@pytest.mark.parametrize('func', [
lambda x: x.std(),
lambda x: x.groupby('x').std(),
lambda x: x.groupby('x').var(),
lambda x: x.groupby('x').mean(),
lambda x: x.groupby('x').sum(),
lambda x: x.groupby('x').z.std(),
])
def test_std_object_dtype(func):
df = pd.DataFrame({
'x': [1, 2, 1],
'y': ['a', 'b', 'c'],
'z': [11., 22., 33.],
})
ddf = dd.from_pandas(df, npartitions=2)

assert_eq(func(df), func(ddf))
19 changes: 19 additions & 0 deletions dask/dataframe/tests/test_groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -1516,3 +1516,22 @@ def test_groupby_select_column_agg():
actual = ddf.groupby('A')['B'].agg('var')
expected = pdf.groupby('A')['B'].agg('var')
assert_eq(actual, expected)


@pytest.mark.parametrize('func', [
lambda x: x.std(),
lambda x: x.groupby('x').std(),
lambda x: x.groupby('x').var(),
lambda x: x.groupby('x').mean(),
lambda x: x.groupby('x').sum(),
lambda x: x.groupby('x').z.std(),
])
def test_std_object_dtype(func):
df = pd.DataFrame({
'x': [1, 2, 1],
'y': ['a', 'b', 'c'],
'z': [11., 22., 33.],
})
ddf = dd.from_pandas(df, npartitions=2)

assert_eq(func(df), func(ddf))

0 comments on commit 51a25ab

Please sign in to comment.