Srinivas Iyyer wrote:
|
for i in list_b:
| ... co = i.split('\t')[2]
| ... items = da.get(co)
^
-|
|
Are you sure that all co's are in da?
One other thing that occurs to me from looking at your dictionary approach is
On Thu, 23 Mar 2006, Kent Johnson wrote:
> This is more efficient than the original algorithm because it reduces
> the size of the loops to the number of matching elements rather than the
> whole number of elements. But if there are a large number of matches it
> will still be a lot of loops!
Terry Carroll wrote:
> On Wed, 22 Mar 2006, Srinivas Iyyer wrote:
>
>
>>I cannot think of any other smart method since these
>>are the only two ways I know possible.
>>
>>Would any one please help me suggesting a neat and
>>efficient way.
>
>
> I'm thinking:
>
> 1) use sets to get subsets o
Thank you Terry,
I learned some stuff from your snippet. I used 'Set'
but never got to use its power using LC.
Thanks again
Srini
--- Terry Carroll <[EMAIL PROTECTED]> wrote:
> On Wed, 22 Mar 2006, Srinivas Iyyer wrote:
>
> > I cannot think of any other smart method since
> these
> > are
Hi Danny,
Thanks for reminding me the tip from Kent :-)
da = {}
for m in list_a:
cols = m.split('\t')
ter = cols[0]
da.setdefault(ter,[]).append(m)
>>> da
{'S66427': ['S66427\tNM_002892'], 'U05861':
['U05861\tNM_001353'], 'D63483': ['D63483\tNM_145349',
'D63483\tNM_003693',
On Wed, 22 Mar 2006, Srinivas Iyyer wrote:
> I cannot think of any other smart method since these
> are the only two ways I know possible.
>
> Would any one please help me suggesting a neat and
> efficient way.
I'm thinking:
1) use sets to get subsets of both lists down to only those element
> Although dictionary is superfast, due to duplications
> in both columns of list_a, a dictionary option falls
> out.
Hi Srinivas,
A dictionary method can work perfectly well.
The assumption that I think is being made is that dictionary values are
restricted to single values. But dictionaries a
Dear group,
I have a question for solving a problem in more
simplistic and efficient way.
I have two lists:
list_a = ['S83513\tNM_001117', 'X60435\tNM_001117',
'U75370\tNM_005035', 'U05861\tNM_001353',
'S68290\tNM_001353', 'D86864\tNM_145349',
'D86864\tNM_003693', 'D86864\tNM_145351',
'D63483\t