Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: groupby behaviour

Thread Tools

Re: groupby behaviour

Ian Kelly
Posts: n/a
On Tue, Feb 26, 2013 at 9:27 AM, andrea crotti
<(E-Mail Removed)> wrote:
> So I was trying to use groupby (which I used in the past), but I
> noticed a very strange thing if using list on
> the result:

As stated in the docs:

The returned group is itself an iterator that shares the underlying
iterable with groupby(). Because the source is shared, when the
groupby() object is advanced, the previous group is no longer visible.
So, if that data is needed later, it should be stored as a list:
Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: groupby behaviour andrea crotti Python 1 02-26-2013 05:35 PM
groupby behaviour andrea crotti Python 0 02-26-2013 04:27 PM
groupby Bryan Python 4 05-27-2006 04:52 PM
Problem with itertools.groupby. Python 3 05-25-2006 09:54 PM
whatsnew 2.4 about itertools.groupby: G?nter Jantzen Python 0 06-09-2004 11:00 AM