Reputation: 345
I want to get a count of values greater than 350 and a second count of values greater than 510. I just need a single number for each count. I have seen some ways of getting counts, but they didn't appear to work for my purpose. Thanks for any help.
print(simfourty48)
[ array([ 99.06, 180.15, 234.21, 369.36, 171.14, 162.13, 54.01,
324.31, 171.14, 108.07, 225.2 , 243.22, 306.29, 144.11,
450.45, 693.72, 225.2 , 486.49, 810.85, 243.22, 279.26,
135.1 , 261.24, 405.4 , 126.09, 261.24, 162.13, 234.21, 45. ])]
Upvotes: 1
Views: 185
Reputation: 309929
Have you tried numpy.count_nonzero
?
np.count_nonzero(simfourty48 > 350)
np.count_nonzero(simfourty48 > 510)
Actually, looking at simfourty48
, it looks like you have a list
whose only element is an np.ndarray
. In that case it would be:
np.count_nonzero(simfourty48[0] > 350)
But I'd recommend rethinking the list with 1 array datastructure if possible. That seems like it will just end up making your life more difficult.
Upvotes: 2