Skip to content

Commit c861f49

Browse files
committed
Cleaned up group_all code
1 parent fea015b commit c861f49

File tree

1 file changed

+2
-11
lines changed

1 file changed

+2
-11
lines changed

pandas/_libs/groupby.pyx

+2-11
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ from algos cimport (swap, TiebreakEnumType, TIEBREAK_AVERAGE, TIEBREAK_MIN,
2020
TIEBREAK_MAX, TIEBREAK_FIRST, TIEBREAK_DENSE)
2121
from algos import take_2d_axis1_float64_float64, groupsort_indexer, tiebreakers
2222

23-
import missing
24-
2523
cdef int64_t iNaT = get_nat()
2624

2725
cdef double NaN = <double> np.NaN
@@ -380,13 +378,6 @@ def group_all(ndarray[uint8_t] out,
380378
ndarray[int64_t] bool_mask
381379
ndarray[uint8_t] isna_mask
382380

383-
if values.dtype == 'object':
384-
bool_mask = np.array([bool(x) for x in values]).astype(np.int64)
385-
isna_mask = missing.isnaobj(values).astype(np.uint8)
386-
else:
387-
bool_mask = values.astype(np.bool).astype(np.int64)
388-
isna_mask = np.isnan(values).astype(np.uint8)
389-
390381
# Because the 'all' value of an empty iterable in Python is True we can
391382
# start with an array full of ones and set to zero when a False value is
392383
# encountered
@@ -395,10 +386,10 @@ def group_all(ndarray[uint8_t] out,
395386
with nogil:
396387
for i in range(N):
397388
lab = labels[i]
398-
if lab < 0 or (skipna and isna_mask[i]):
389+
if lab < 0 or (skipna and mask[i]):
399390
continue
400391

401-
if not bool_mask[i]:
392+
if not values[i]:
402393
out[lab] = 0
403394

404395

0 commit comments

Comments
 (0)