You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[FEA] Accumulate integral groupby MEAN in its double output type #25005
Is your feature request related to a problem? Please describe.
For integral inputs, groupby MEAN returns double but accumulates in the int64 SUM type. It reuses the SUM result and divides by the count afterward (hash_compound_agg_finalizer.cu, sort/aggregate.cpp). A group whose sum exceeds the int64 range returns a wrapped mean even though the mean itself fits.
Reduction MEAN doesn't have this problem. op::mean in reduction_operators.cuh casts each element to the double result type before summing. As a result, the same column gives a correct mean from cudf::reduce and a wrapped one from cudf::groupby.
pandas also accumulates groupby MEAN in float64, while its int64 sum wraps:
M, m=np.iinfo(np.int64).max, np.iinfo(np.int64).mindf=pd.DataFrame({"k": [0, 0, 1, 1, 1], "v": np.array([M, M, m, m, m], dtype="int64")})
df.groupby("k").v.sum() # -2, -9223372036854775808df.groupby("k").v.mean() # 9.223372e+18, -9.223372e+18
Activity