Skip to content

Commit 64f2798

Browse files
committed
Fix group_sum NaN comparison warnings
1 parent b983366 commit 64f2798

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

pandas/_libs/groupby.pyx

+6-10
Original file line numberDiff line numberDiff line change
@@ -744,21 +744,17 @@ def group_sum(
744744
for j in range(K):
745745
val = values[i, j]
746746

747-
if not skipna and (
748-
(uses_mask and result_mask[lab, j]) or
749-
(is_datetimelike and sumx[lab, j] == NPY_NAT) or
750-
_treat_as_na(sumx[lab, j], False)
751-
):
752-
# If sum is already NA, don't add to it. This is important for
753-
# datetimelikebecause adding a value to NPY_NAT may not result
754-
# in a NPY_NAT
755-
continue
756-
757747
if uses_mask:
758748
isna_entry = mask[i, j]
759749
else:
760750
isna_entry = _treat_as_na(val, is_datetimelike)
761751

752+
if not skipna and isna_entry:
753+
# If sum is already NA, don't add to it. This is important for
754+
# datetimelikebecause adding a value to NPY_NAT may not result
755+
# in a NPY_NAT
756+
continue
757+
762758
if not isna_entry:
763759
nobs[lab, j] += 1
764760

0 commit comments

Comments
 (0)