[Baypiggies] nested list question
jason at mischievous.org
Tue Jun 28 00:29:30 CEST 2011
On Jun 27, 2011, at 2:06 PM, Vikram K wrote:
> Suppose i have the following nested list:
> >>> x
> [['19600894', '1', 'chr15_76136768', 'MISSENSE'], ['19600894', '2', 'chr15_76136768', 'MISSENSE'], ['18467762', '1', 'chr14_23354066', 'MISSENSE']]
> How do i obtain from nested list x (given above), the following nested list z:
> >>> z
> [['chr15_76136768', 'MISSENSE'], ['chr14_23354066', 'MISSENSE']]
list(unique_everseen((y[2:4] for y in x), operator.itemgetter(0)))
or the whole nested list with just
unique_everseen is from
If you data is already sorted by the key then
might be more efficient?
> In other words, if the third element of an element of x is the same, then i wish to combine it into a single element.
> Baypiggies mailing list
> Baypiggies at python.org
> To change your subscription options or unsubscribe:
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Baypiggies