Skip to content

Commit 6f2c60e

Browse files
authored
CLN: Unify Series case in _wrap_applied_output (#36504)
1 parent e975f3d commit 6f2c60e

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

pandas/core/groupby/generic.py

+6-9
Original file line numberDiff line numberDiff line change
@@ -1190,14 +1190,6 @@ def _wrap_applied_output(self, keys, values, not_indexed_same=False):
11901190

11911191
key_index = self.grouper.result_index if self.as_index else None
11921192

1193-
if isinstance(first_not_none, Series):
1194-
# this is to silence a DeprecationWarning
1195-
# TODO: Remove when default dtype of empty Series is object
1196-
kwargs = first_not_none._construct_axes_dict()
1197-
backup = create_series_with_explicit_dtype(dtype_if_empty=object, **kwargs)
1198-
1199-
values = [x if (x is not None) else backup for x in values]
1200-
12011193
if isinstance(first_not_none, (np.ndarray, Index)):
12021194
# GH#1738: values is list of arrays of unequal lengths
12031195
# fall through to the outer else clause
@@ -1217,8 +1209,13 @@ def _wrap_applied_output(self, keys, values, not_indexed_same=False):
12171209
result = DataFrame(values, index=key_index, columns=[self._selection])
12181210
self._insert_inaxis_grouper_inplace(result)
12191211
return result
1220-
12211212
else:
1213+
# this is to silence a DeprecationWarning
1214+
# TODO: Remove when default dtype of empty Series is object
1215+
kwargs = first_not_none._construct_axes_dict()
1216+
backup = create_series_with_explicit_dtype(dtype_if_empty=object, **kwargs)
1217+
values = [x if (x is not None) else backup for x in values]
1218+
12221219
all_indexed_same = all_indexes_same(x.index for x in values)
12231220

12241221
# GH3596

0 commit comments

Comments
 (0)