Counting number of values between interval

Posted by calccrypto on Stack Overflow See other posts from Stack Overflow or by calccrypto
Published on 2010-05-31T23:46:41Z Indexed on 2010/06/01 0:03 UTC
Read the original article Hit count: 138

Filed under:
|
|

Is there any efficient way in python to count the times an array of numbers is between certain intervals? the number of intervals i will be using may get quite large

like:

mylist = [4,4,1,18,2,15,6,14,2,16,2,17,12,3,12,4,15,5,17]

some function(mylist, startpoints):
   # startpoints = [0,10,20]
   count values in range [0,9]
   count values in range [10-19]

output = [9,10]

© Stack Overflow or respective owner

Related posts about python

Related posts about array