Skip to content

Commit

Permalink
Fix group_sum NaN comparison warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
WillAyd committed Jan 21, 2025
1 parent b983366 commit 64f2798
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions pandas/_libs/groupby.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -744,21 +744,17 @@ def group_sum(
for j in range(K):
val = values[i, j]

if not skipna and (
(uses_mask and result_mask[lab, j]) or
(is_datetimelike and sumx[lab, j] == NPY_NAT) or
_treat_as_na(sumx[lab, j], False)
):
# If sum is already NA, don't add to it. This is important for
# datetimelikebecause adding a value to NPY_NAT may not result
# in a NPY_NAT
continue

if uses_mask:
isna_entry = mask[i, j]
else:
isna_entry = _treat_as_na(val, is_datetimelike)

if not skipna and isna_entry:
# If sum is already NA, don't add to it. This is important for
# datetimelikebecause adding a value to NPY_NAT may not result
# in a NPY_NAT
continue

if not isna_entry:
nobs[lab, j] += 1

Expand Down

0 comments on commit 64f2798

Please sign in to comment.