Hi Steve! I am not sure if I was clear with my previous post .Ok let me rephrase it .
Assume the values list is the content of a histogram. Then we see that values = [ 0, 72, 2, 4, 9, 2, 0, 0, 42, 26, 0, 282, 23, 0, 101, 0, 0, 0, 0, 0] 1 is repeated 72 times, 3 -> 4 times and so on. That is the index would be the value repeated as many times as in the list. Now If we find the max and look for the adjcent index. That is if we plot the above list as a histogram. We will have crests and troughs ie peaks and dips. if we find two dips then the region between the two dips could be a range like [0, 72, 2] .So here we are not looking for a zero. But if we find dips then we consider the regions between it as a bin and group it. | /\ | /\ / \ /\ | / \/ \/ \ |/_____________________________________ |----|-----|---| 1 2 3 so pictorially. In the above plot. If y axis is the list above. then we need to bin it this way. If I use you previous approach using the groupby then all these three regions will be considered as one. Hope I am clear this time. -- http://mail.python.org/mailman/listinfo/python-list