File tree 1 file changed +9
-11
lines changed
1 file changed +9
-11
lines changed Original file line number Diff line number Diff line change @@ -712,7 +712,7 @@ def group_sum(
712
712
int64_t[:, ::1] nobs
713
713
Py_ssize_t len_values = len (values), len_labels = len (labels)
714
714
bint uses_mask = mask is not None
715
- bint isna_entry
715
+ bint isna_entry , isna_result
716
716
717
717
if len_values != len_labels:
718
718
raise ValueError("len(index ) != len(labels )")
@@ -744,20 +744,18 @@ def group_sum(
744
744
for j in range (K):
745
745
val = values[i, j]
746
746
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
-
757
747
if uses_mask:
758
748
isna_entry = mask[i, j]
749
+ isna_result = result_mask[lab, j]
759
750
else :
760
751
isna_entry = _treat_as_na(val, is_datetimelike)
752
+ isna_result = _treat_as_na(sumx[lab, j], is_datetimelike)
753
+
754
+ if not skipna and isna_result:
755
+ # If sum is already NA, don't add to it. This is important for
756
+ # datetimelikebecause adding a value to NPY_NAT may not result
757
+ # in a NPY_NAT
758
+ continue
761
759
762
760
if not isna_entry:
763
761
nobs[lab, j] += 1
You can’t perform that action at this time.
0 commit comments