Re: Hi, friends. I wanna ask if there is a function which is able to take a list as argument and then return its top-k maximums?

2010-04-23 Thread Raymond Hettinger
On Apr 23, 1:24 am, Bryan wrote: > That is interesting. The above algorithm for nlargest is better, but > to use it for nsmallest requires a largest-on-top heap, which the > module does not bother to implement. FWIW, the pure python versions differ because they are both implemented in terms of th

Re: Hi, friends. I wanna ask if there is a function which is able to take a list as argument and then return its top-k maximums?

2010-04-23 Thread Raymond Hettinger
On Apr 22, 10:49 am, John Nagle wrote: > Chris Rebert wrote: > > 2010/4/22 Jo Chan : > >> Hi,friends. > >>  I wanna ask if there is a function which is able to take a list as > >> argument > >> and then return its top-k maximums? > >>

Re: Hi, friends. I wanna ask if there is a function which is able to take a list as argument and then return its top-k maximums?

2010-04-23 Thread Steven Howe
Really! Learn to use google better. I just used "python sort list" Look at: http://wiki.python.org/moin/HowTo/Sorting Read about list.sort. Try, at a command prompt (assuming you have a unix shell), "pydoc list" search for sort; read it. It mentions 'reverse'. then slice the list to your desi

Re: Hi, friends. I wanna ask if there is a function which is able to take a list as argument and then return its top-k maximums?

2010-04-23 Thread Grant Edwards
On 2010-04-22, D'Arcy J.M. Cain wrote: > On Thu, 22 Apr 2010 15:04:01 +0100 > Tim Golden wrote: >> > So please tell me if there is one or not. I really need this soon. >> > Appreciate a lot. >> >> Assuming top-k doesn't mean something obscurely statistical: > > You really shouldn't do people's h

Re: Hi, friends. I wanna ask if there is a function which is able to take a list as argument and then return its top-k maximums?

2010-04-23 Thread Bryan
Steven D'Aprano wrote: > John Nagle wrote: > >    Is "nlargest" smart enough to decide when it's cheaper to track the > > N largest entries on a linear pass through the list than to sort? It *always* does a linear pass through the list (linear, that is in the length of the entire list). It tracks

Re: Hi, friends. I wanna ask if there is a function which is able to take a list as argument and then return its top-k maximums?

2010-04-22 Thread Steven D'Aprano
On Thu, 22 Apr 2010 10:49:29 -0700, John Nagle wrote: >Is "nlargest" smart enough to decide when it's cheaper to track the > N largest entries on a linear pass through the list than to sort? Doesn't appear to do so. From Python 3.1: def nlargest(n, iterable): """Find the n largest elemen

Re: Hi, friends. I wanna ask if there is a function which is able to take a list as argument and then return its top-k maximums?

2010-04-22 Thread Rhodri James
On Thu, 22 Apr 2010 15:23:29 +0100, D'Arcy J.M. Cain wrote: On Fri, 23 Apr 2010 00:07:18 +1000 Xavier Ho wrote: > print (sorted (l, reverse=True)[:k]) You don't really need to reverse sort there: True but... >>> numbers = [1, 4, 5, 3, 7, 8] >>> sorted(numbers)[3:] [5, 7, 8] Now try r

Re: Hi, friends. I wanna ask if there is a function which is able to take a list as argument and then return its top-k maximums?

2010-04-22 Thread John Nagle
Chris Rebert wrote: 2010/4/22 Jo Chan : Hi,friends. I wanna ask if there is a function which is able to take a list as argument and then return its top-k maximums? I only know about max which is poorly a top-1 maximum function, now I want more yet I am lazy enough that don't want to writ

Re: Hi, friends. I wanna ask if there is a function which is able to take a list as argument and then return its top-k maximums?

2010-04-22 Thread D'Arcy J.M. Cain
On Thu, 22 Apr 2010 15:04:01 +0100 Tim Golden wrote: > > So please tell me if there is one or not. I really need this soon. > > Appreciate a lot. > > Assuming top-k doesn't mean something obscurely statistical: You really shouldn't do people's homework for them. It doesn't do them any favours.

Re: Hi, friends. I wanna ask if there is a function which is able to take a list as argument and then return its top-k maximums?

2010-04-22 Thread Xavier Ho
On Fri, Apr 23, 2010 at 12:23 AM, D'Arcy J.M. Cain wrote: > Now try returning the top two or four numbers. > >>> numbers = [1, 4, 5, 3, 7, 8] >>> sorted(numbers)[-2:] [7, 8] >>> sorted(numbers)[-4:] [4, 5, 7, 8] I see what you mean. This is not as intuitive, is it? Cheers, Xav -- http://mail

Re: Hi, friends. I wanna ask if there is a function which is able to take a list as argument and then return its top-k maximums?

2010-04-22 Thread D'Arcy J.M. Cain
On Fri, 23 Apr 2010 00:07:18 +1000 Xavier Ho wrote: > > print (sorted (l, reverse=True)[:k]) > > You don't really need to reverse sort there: True but... > >>> numbers = [1, 4, 5, 3, 7, 8] > >>> sorted(numbers)[3:] > [5, 7, 8] Now try returning the top two or four numbers. -- D'Arcy J.M. Cai

Re: Hi, friends. I wanna ask if there is a function which is able to take a list as argument and then return its top-k maximums?

2010-04-22 Thread Jo Chan
Yeah... but actually I need something more efficient, like heap. Thank you for your help though. Best regards, Songjian On Thu, Apr 22, 2010 at 10:04 PM, Tim Golden wrote: > On 22/04/2010 14:57, Jo Chan wrote: > > Hi,friends. > > > > I wanna ask if there is a function

Re: Hi, friends. I wanna ask if there is a function which is able to take a list as argument and then return its top-k maximums?

2010-04-22 Thread Jo Chan
Cool! Thanks a lot! That's exactly what I want. Best regards, Songjian On Thu, Apr 22, 2010 at 10:04 PM, Chris Rebert wrote: > 2010/4/22 Jo Chan : > > Hi,friends. > > I wanna ask if there is a function which is able to take a list as > argument > > and then ret

Re: Hi, friends. I wanna ask if there is a function which is able to take a list as argument and then return its top-k maximums?

2010-04-22 Thread Xavier Ho
On Fri, Apr 23, 2010 at 12:04 AM, Tim Golden wrote: > Assuming top-k doesn't mean something obscurely statistical: > > l = [1,2, 3, 4, 5] > k = 3 > print (sorted (l, reverse=True)[:k]) > You don't really need to reverse sort there: >>> numbers = [1, 4, 5, 3, 7, 8] >>> sorted(numbers)[3:] [5, 7,

Re: Hi, friends. I wanna ask if there is a function which is able to take a list as argument and then return its top-k maximums?

2010-04-22 Thread Chris Rebert
2010/4/22 Jo Chan : > Hi,friends. >  I wanna ask if there is a function which is able to take a list as argument > and then return its top-k maximums? > I only know about max which is poorly a top-1 maximum function, now I want > more yet I am lazy enough that don't want to

Re: Hi, friends. I wanna ask if there is a function which is able to take a list as argument and then return its top-k maximums?

2010-04-22 Thread Tim Golden
On 22/04/2010 14:57, Jo Chan wrote: > Hi,friends. > > I wanna ask if there is a function which is able to take a list as argument > and then return its top-k maximums? > I only know about max which is poorly a top-1 maximum function, now I want > more yet I am lazy enough

Hi, friends. I wanna ask if there is a function which is able to take a list as argument and then return its top-k maximums?

2010-04-22 Thread Jo Chan
Hi,friends. I wanna ask if there is a function which is able to take a list as argument and then return its top-k maximums? I only know about max which is poorly a top-1 maximum function, now I want more yet I am lazy enough that don't want to write one by myself. So please tell me if the

hi friends........... google group invites you a won dering world of businesss ............. do u want to earn mil lions of dollers per month through online jobs joined with me and find the way to ea

2008-03-24 Thread bright
hi friends... google group invites you a wondering world of businesss . do u want to earn millions of dollers per month through online jobs joined with me and find the way to earn dollers. visit us www.jobsforyouguys.blogspot.co­m -- http://mail.python.org/mailman

hi friends

2007-11-05 Thread sindhu_jjcet
to get preapred for the business see bird-flumanual.com log on to http://www.geocities.com/humnoses/ -- http://mail.python.org/mailman/listinfo/python-list