Skip to content

Commit 14666a1

Browse files
committed
Fixed sparse test cases
1 parent 9502ba4 commit 14666a1

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

pandas/core/groupby/groupby.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ class providing the base-class of operations.
2727
)
2828
from pandas.core.config import option_context
2929
from pandas.core.dtypes.cast import maybe_downcast_to_dtype
30-
from pandas.core.dtypes.common import ensure_float, is_numeric_dtype, is_scalar, is_extension_array_dtype
30+
from pandas.core.dtypes.common import (
31+
ensure_float, is_numeric_dtype, is_scalar, is_extension_array_dtype
32+
)
3133
from pandas.core.dtypes.missing import isna, notna
3234
from pandas.core.frame import DataFrame
3335
from pandas.core.generic import NDFrame

pandas/tests/sparse/test_groupby.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,25 +26,25 @@ def test_first_last_nth(self):
2626

2727
# TODO: shouldn't these all be spares or not?
2828
tm.assert_frame_equal(sparse_grouped.first(),
29-
dense_grouped.first())
29+
dense_grouped.first().to_sparse())
3030
tm.assert_frame_equal(sparse_grouped.last(),
31-
dense_grouped.last())
31+
dense_grouped.last().to_sparse())
3232
tm.assert_frame_equal(sparse_grouped.nth(1),
3333
dense_grouped.nth(1).to_sparse())
3434

3535
def test_aggfuncs(self):
3636
sparse_grouped = self.sparse.groupby('A')
3737
dense_grouped = self.dense.groupby('A')
3838

39-
tm.assert_frame_equal(sparse_grouped.mean(),
40-
dense_grouped.mean())
39+
tm.assert_frame_equal(sparse_grouped.mean().to_sparse(),
40+
dense_grouped.mean().to_sparse())
4141

4242
# ToDo: sparse sum includes str column
4343
# tm.assert_frame_equal(sparse_grouped.sum(),
4444
# dense_grouped.sum())
4545

46-
tm.assert_frame_equal(sparse_grouped.count(),
47-
dense_grouped.count())
46+
tm.assert_frame_equal(sparse_grouped.count().to_sparse(),
47+
dense_grouped.count().to_sparse())
4848

4949

5050
@pytest.mark.parametrize("fill_value", [0, np.nan])

0 commit comments

Comments
 (0)