I have a NumPy array \'boolarr\' of boolean type. I want to count the number of elements whose values are True. Is there a NumPy or Python routine dedicated for
True
boolarr.sum(axis=1 or axis=0)
axis = 1 will output number of trues in a row and axis = 0 will count number of trues in columns so
boolarr[[true,true,true],[false,false,true]] print(boolarr.sum(axis=1))
will be (3,1)