Add multiple values to one numpy array index

This is what the at method of NumPy ufuncs is for:

output = numpy.zeros(size)
numpy.add.at(output, a[a.cond].ix, a[a.cond].val)

Leave a Comment