This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author petri.lehtinen
Recipients Jiba, petri.lehtinen
Date 2012-05-16.10:23:07
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1337163787.68.0.431355112879.issue14828@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2012-05-16 10:23:07petri.lehtinensetrecipients: + petri.lehtinen, Jiba
2012-05-16 10:23:07petri.lehtinensetmessageid: <1337163787.68.0.431355112879.issue14828@psf.upfronthosting.co.za>
2012-05-16 10:23:07petri.lehtinenlinkissue14828 messages
2012-05-16 10:23:07petri.lehtinencreate