Skip to content

Commit d54c743

Browse files
committed
test case dataframe assertion added
1 parent 44287de commit d54c743

File tree

2 files changed

+6
-17
lines changed

2 files changed

+6
-17
lines changed

pandas/core/groupby/groupby.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class providing the base-class of operations.
2828
from pandas.core.config import option_context
2929
from pandas.core.dtypes.cast import maybe_downcast_to_dtype
3030
from pandas.core.dtypes.common import (
31-
ensure_float, is_numeric_dtype, is_scalar, is_extension_array_dtype
31+
ensure_float, is_extension_array_dtype, is_numeric_dtype, is_scalar
3232
)
3333
from pandas.core.dtypes.missing import isna, notna
3434
from pandas.core.frame import DataFrame

pandas/tests/arrays/test_integer.py

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -674,22 +674,11 @@ def test_reduce_to_float(op):
674674
# groupby
675675
result = getattr(df.groupby("A"), op)()
676676

677-
assert result.dtypes['B'].name == 'float64'
678-
assert result.dtypes['C'].name == 'Int64'
679-
680-
681-
@pytest.mark.parametrize('op', ['sum'])
682-
def test_groupby_extension_array(op):
683-
# GH23227
684-
# groupby on an extension array should return the extension array type
685-
df = pd.DataFrame({
686-
'Int': pd.Series([1, 2, 3], dtype='Int64'),
687-
'A': [1, 2, 1]
688-
})
689-
690-
result = getattr(df.groupby('A').Int, op)()
691-
assert result is not None
692-
assert result.dtype.name == 'Int64'
677+
expected = pd.DataFrame({
678+
"B": np.array([1.0, 3.0]),
679+
"C": integer_array([1, 3], dtype="Int64")
680+
}, index=pd.Index(['a', 'b'], name='A'))
681+
tm.assert_frame_equal(result, expected)
693682

694683

695684
def test_astype_nansafe():

0 commit comments

Comments
 (0)