Re: Identify runs in list

2009-10-03 Thread Paul Rubin
"skorpi...@gmail.com" writes: > Any suggestions would be appreciated Look at the docs of the groupby function in the itertools module. -- http://mail.python.org/mailman/listinfo/python-list

Re: Identify runs in list

2009-10-03 Thread Chris Rebert
On Sat, Oct 3, 2009 at 7:53 PM, skorpi...@gmail.com wrote: > On Oct 3, 10:36 pm, Chris Rebert wrote: >> Since this sounds like homework, I won't give actual code, but here's >> a gameplan: >> >> 1. Split the list into sublists based on where the runs of zeros stop and >> start. >> 2. Categorize

Re: Identify runs in list

2009-10-03 Thread skorpi...@gmail.com
On Oct 3, 10:36 pm, Chris Rebert wrote: > On Sat, Oct 3, 2009 at 7:21 PM, skorpi...@gmail.com > wrote: > > Hi all, > > > I have a data structure in a list as in: [0 0 0 3 0 5 0 0 0 0 1 0 4 0 > > 5 0 0 7 0 0 0 0 0 12 0 0 4] > > > I would like to extract three list from this data: > > > 1) runsOfZ

Re: Identify runs in list

2009-10-03 Thread Chris Rebert
On Sat, Oct 3, 2009 at 7:21 PM, skorpi...@gmail.com wrote: > Hi all, > > I have a data structure in a list as in: [0 0 0 3 0 5 0 0 0 0 1 0 4 0 > 5 0 0 7 0 0 0 0 0 12 0 0 4] > > I would like to extract three list from this data: > > 1) runsOfZero: [3 4 5] > 2) runsOfNonZero: [3 8 4] > 3) SumOfRunsO

Identify runs in list

2009-10-03 Thread skorpi...@gmail.com
Hi all, I have a data structure in a list as in: [0 0 0 3 0 5 0 0 0 0 1 0 4 0 5 0 0 7 0 0 0 0 0 12 0 0 4] I would like to extract three list from this data: 1) runsOfZero: [3 4 5] 2) runsOfNonZero: [3 8 4] 3) SumOfRunsOfNonZero: [8 17 16] Any suggestions would be appreciated -- http://mail.pyt