I have 2 list of lists as follows:
A = [[],[],[],[500,540],[510,560,550],[460,510,600,450]]
B = [[],[],[],[4000,2500],[3500,3600,3000],[3000,2900,3300,3500]]
I would like to calculate the weighted average of values in every list of A using lists of B as corresponding weights. My output C should like like:
C = [[],[],[],[515],[540],[505]]
What I tried so far is using
C = []
for i in range(len(A)):
avg = np.average(A[i], weights=B[i])
C.append(avg)
Many thanks for your help.