Skip to content

Commit 21e1fca

Browse files
committed
Refactored if-else.
1 parent aa02b83 commit 21e1fca

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

pandas/core/groupby/generic.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1223,6 +1223,8 @@ def _wrap_applied_output(self, keys, values, not_indexed_same=False):
12231223
if isinstance(first_not_none, DataFrame):
12241224
return self._concat_objects(keys, values, not_indexed_same=not_indexed_same)
12251225

1226+
key_index = self.grouper.result_index if self.as_index else None
1227+
12261228
if isinstance(first_not_none, NDFrame):
12271229

12281230
# this is to silence a DeprecationWarning
@@ -1236,11 +1238,7 @@ def _wrap_applied_output(self, keys, values, not_indexed_same=False):
12361238
backup = first_not_none._constructor(**kwargs)
12371239

12381240
values = [x if (x is not None) else backup for x in values]
1239-
1240-
key_index = self.grouper.result_index if self.as_index else None
1241-
v = values[0]
1242-
1243-
if not isinstance(v, (np.ndarray, Index, Series)):
1241+
else:
12441242
# values are not series or array-like but scalars
12451243
# self._selection_name not passed through to Series as the
12461244
# result should not take the name of original selection
@@ -1252,6 +1250,8 @@ def _wrap_applied_output(self, keys, values, not_indexed_same=False):
12521250
self._insert_inaxis_grouper_inplace(result)
12531251
return result
12541252

1253+
v = values[0]
1254+
12551255
if not isinstance(v, ABCSeries):
12561256
# GH1738: values is list of arrays of unequal lengths
12571257
# TODO: sure this is right? we used to do this

0 commit comments

Comments
 (0)