If you use boolean array indexing to specify subscripts using a conditional expression,
# numpy array for testing
arr = numpy.array(list(range(10))))
# output sumif
print(arr[arr>5].sum())
# Output countif
print(numpy.sum(arr>5))
You can write as shown in
--Metropolis's Commentsfrom
© 2024 OneMinuteCode. All rights reserved.