Sum array values based on conditions in other arrays I have the following code that sums the values in wgt_dif (a numpy array) if certain conditions in two other numpy arrays are met. It is basically the equivalent of a SUMIFS function in Excel. 

sum_4s = 0

for i in range(len(pntl)):
    if pntl[i] == 4 and adj_wgt[i] != max_wgt:
        sum_4s += wgt_dif[i]


I'm wondering if there is a more Pythonic way to write this. It works fine, but I'm new to Python and numpy and would like to expand my "vocabulary".
sum([w for w, p, a in zip(wgt_dif, pntl, adj_wgt) if p == 4 and a != max_wgt])




Explanation:

zip(a, b, c) 


creates the list of triplets of corresponding values from the lists a, b, c - something as 

[(a[0], b[0], c[0]), (a[1], b[1], c[1]), (a[2], b[2], c[2]), ...]


so the part

for w, p, a in zip(wgt_dif, pntl, adj_wgt)


loops over this triples, associating th 1st item to w, 2nd to p, and 3rd to a.