Skip to content

Commit 8837b36

Browse files
[ArrayManager] Groupby cython aggregation - python pyfallback (#40047)
1 parent cf8c7d5 commit 8837b36

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

pandas/core/groupby/generic.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -1120,19 +1120,20 @@ def cast_agg_result(result, values: ArrayLike, how: str) -> ArrayLike:
11201120

11211121
return result
11221122

1123-
def py_fallback(bvalues: ArrayLike) -> ArrayLike:
1123+
def py_fallback(values: ArrayLike) -> ArrayLike:
11241124
# if self.grouper.aggregate fails, we fall back to a pure-python
11251125
# solution
11261126

11271127
# We get here with a) EADtypes and b) object dtype
11281128
obj: FrameOrSeriesUnion
11291129

11301130
# call our grouper again with only this block
1131-
if isinstance(bvalues, ExtensionArray):
1131+
if isinstance(values, ExtensionArray) or values.ndim == 1:
11321132
# TODO(EA2D): special case not needed with 2D EAs
1133-
obj = Series(bvalues)
1133+
obj = Series(values)
11341134
else:
1135-
obj = DataFrame(bvalues.T)
1135+
# TODO special case not needed with ArrayManager
1136+
obj = DataFrame(values.T)
11361137
if obj.shape[1] == 1:
11371138
# Avoid call to self.values that can occur in DataFrame
11381139
# reductions; see GH#28949

pandas/tests/groupby/aggregate/test_aggregate.py

-3
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,6 @@ def test_agg_index_has_complex_internals(index):
495495
tm.assert_frame_equal(result, expected)
496496

497497

498-
@td.skip_array_manager_not_yet_implemented # TODO(ArrayManager) agg py_fallback
499498
def test_agg_split_block():
500499
# https://github.com/pandas-dev/pandas/issues/31522
501500
df = DataFrame(
@@ -513,7 +512,6 @@ def test_agg_split_block():
513512
tm.assert_frame_equal(result, expected)
514513

515514

516-
@td.skip_array_manager_not_yet_implemented # TODO(ArrayManager) agg py_fallback
517515
def test_agg_split_object_part_datetime():
518516
# https://github.com/pandas-dev/pandas/pull/31616
519517
df = DataFrame(
@@ -1205,7 +1203,6 @@ def test_aggregate_datetime_objects():
12051203
tm.assert_series_equal(result, expected)
12061204

12071205

1208-
@td.skip_array_manager_not_yet_implemented # TODO(ArrayManager) agg py_fallback
12091206
def test_aggregate_numeric_object_dtype():
12101207
# https://github.com/pandas-dev/pandas/issues/39329
12111208
# simplified case: multiple object columns where one is all-NaN

0 commit comments

Comments
 (0)