You can treat indices as bins and values as weights for np.bincount.
np.bincount
values = np.array([0.0, 1.0, 2.0, 3.0, 4.0]) indices = np.array([0,1,0,2,2]) sums = np.bincount(indices, weights=values)