Petri Lehtinen <pe...@digip.org> added the comment:

groupby() changes the group when the key changes in the input it iterates. If 
you want to have p1 and p3 to go to the same group, you need to sort the input 
by P.key first.

This is clearly documented, too:

    The operation of groupby() is similar to the uniq filter in Unix.
    It generates a break or new group every time the value of the key 
    function changes (which is why it is usually necessary to have 
    sorted the data using the same key function). That behavior differs
    from SQL’s GROUP BY which aggregates common elements regardless of
    their input order.

----------
nosy: +petri.lehtinen
resolution:  -> invalid
status: open -> closed

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue14828>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to