[Numpy-discussion] Find the N maximum values and corresponding indexes in an array
Charles R Harris
Thu Dec 3 11:34:18 CST 2009
On Thu, Dec 3, 2009 at 10:24 AM, Howard Chong <firstname.lastname@example.org> wrote:
> Thanks for all the help and suggestions. I think the partial sort is
> exactly what I need.
> I thought of doing it as a full sort with argsort(), but that would be much
> slower if I just need a small number (maybe 7) from a large array,
> potentially thousands or a million repeated many times.
> In case you are wondering, I am doing this to find the 7 nearest neighbors
> in a GIS. For a list of zipcodes in America, find the 7 nearest weather
Have you looked at the kdtree in scipy? It is aimed precisely at this sort
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the NumPy-Discussion