Skip to content

Commit c5c67dd

Browse files
committed
fix issue #59712
1 parent 1907b35 commit c5c67dd

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

pandas/core/groupby/ops.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -371,19 +371,6 @@ def _call_cython_op(
371371

372372
is_datetimelike = dtype.kind in "mM"
373373

374-
if self.how in ["any", "all"]:
375-
if mask is None:
376-
mask = isna(values)
377-
if dtype == object:
378-
if kwargs["skipna"]:
379-
# GH#37501: don't raise on pd.NA when skipna=True
380-
if mask.any():
381-
# mask on original values computed separately
382-
values = values.copy()
383-
values[mask] = True
384-
values = values.astype(bool, copy=False).view(np.int8)
385-
is_numeric = True
386-
387374
if is_datetimelike:
388375
values = values.view("int64")
389376
is_numeric = True
@@ -398,6 +385,19 @@ def _call_cython_op(
398385
if result_mask is not None:
399386
result_mask = result_mask.T
400387

388+
if self.how in ["any", "all"]:
389+
if mask is None:
390+
mask = isna(values)
391+
if dtype == object:
392+
if kwargs["skipna"]:
393+
# GH#37501: don't raise on pd.NA when skipna=True
394+
if mask.any():
395+
# mask on original values computed separately
396+
values = values.copy()
397+
values[mask] = True
398+
values = values.astype(bool, copy=False).view(np.int8)
399+
is_numeric = True
400+
401401
out_shape = self._get_output_shape(ngroups, values)
402402
func = self._get_cython_function(self.kind, self.how, values.dtype, is_numeric)
403403
values = self._get_cython_vals(values)

0 commit comments

Comments
 (0)