I've been looking at the solutions here and here but failing to see how I can apply it to my structures.
I have 3 arrays: an (M, N)
of zeros, and (P,)
of indexes (some repeat) and an (P, N)
of values.
I can accomplish it with a loop:
# a: (M, N)
# b: (P, N)
# ix: (M,)
for i in range(N):
a[:, i] += np.bincount(ix, weights=b[:, i], minlength=M)
I've not seen any examples that use indexes in this manner, or with the weights
keyword. I understand I need to bring everything into a 1D array to vectorize it, however I am struggling to figure out how to accomplish that.