On 27 May 2007 10:49:06 -0700, 7stud <[EMAIL PROTECTED]> wrote: > On May 27, 11:28 am, Steve Howell <[EMAIL PROTECTED]> wrote: > > The groupby method has its uses, but it's behavior is > > going to be very surprising to anybody that has used > > the "group by" syntax of SQL, because Python's groupby > > method will repeat groups if your data is not sorted, > > whereas SQL has the luxury of (knowing that it's) > > working with a finite data set, so it can provide the > > more convenient semantics. > > The groupby method has its uses > > I'd settle for a simple explanation of what it does in python.
Here is another example: import itertools import random dierolls = sorted(random.randint(1, 6) for x in range(200)) for number, numbers in itertools.groupby(dierolls): number_count = len(list(numbers)) print number, "came up", number_count, "times." -- mvh Björn -- http://mail.python.org/mailman/listinfo/python-list