Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions pandas/core/groupby/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -1120,19 +1120,20 @@ def cast_agg_result(result, values: ArrayLike, how: str) -> ArrayLike:

return result

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

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

# call our grouper again with only this block
if isinstance(bvalues, ExtensionArray):
if isinstance(values, ExtensionArray) or values.ndim == 1:
# TODO(EA2D): special case not needed with 2D EAs
obj = Series(bvalues)
obj = Series(values)
else:
obj = DataFrame(bvalues.T)
# TODO special case not needed with ArrayManager
obj = DataFrame(values.T)
if obj.shape[1] == 1:
# Avoid call to self.values that can occur in DataFrame
# reductions; see GH#28949
Expand Down
3 changes: 0 additions & 3 deletions pandas/tests/groupby/aggregate/test_aggregate.py
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,6 @@ def test_agg_index_has_complex_internals(index):
tm.assert_frame_equal(result, expected)


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


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


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