Steven Bethard wrote:
> py> data = [[('a', 0),
> ... ('b', 1),
> ... ('c', 2)],
> ...
> ... [('d', 2),
> ... ('e', 0)],
> ...
> ... [('f', 0),
> ... ('g', 2),
> ... ('h', 1),
> ... ('i', 0),
> ... ('j', 0)]]
>
> I need
Steven Bethard wrote:
Michael Spencer wrote:
Steven Bethard wrote:
So, I have a list of lists, where the items in each sublist are of
basically the same form. It looks something like:
...
Can anyone see a simpler way of doing this?
Steve
You just make these up to keep us amused, don't you? ;-)
Michael Spencer wrote:
>>> def resample2(data):
... bag = {}
... random.shuffle(data)
... return [[(item, label)
... for item, label in group
... if bag.setdefault(label,[]).append(item)
... or len(bag[label]) < 3]
...
Michael Spencer wrote:
Steven Bethard wrote:
So, I have a list of lists, where the items in each sublist are of
basically the same form. It looks something like:
...
Can anyone see a simpler way of doing this?
Steve
You just make these up to keep us amused, don't you? ;-)
Heh heh. I wish. It's
Steven Bethard wrote:
So, I have a list of lists, where the items in each sublist are of
basically the same form. It looks something like:
...
Can anyone see a simpler way of doing this?
Steve
You just make these up to keep us amused, don't you? ;-)
If you don't need to preserve the ordering, wo