Re: Identify runs in list

2009-10-03 Thread Paul Rubin
"[email protected]" 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, [email protected] 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 [email protected]
On Oct 3, 10:36 pm, Chris Rebert wrote: > On Sat, Oct 3, 2009 at 7:21 PM, [email protected] > 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, [email protected] 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