Solved

reversing output of numpy argsort

Posted on 2013-06-20
7
1,471 Views
Last Modified: 2013-06-25
Hi,

I find it amazing that I can't find an answer online, but how do I use numpy argsort to sort in reverse order?  The documentation is sparse.

I'm sorting a simple array of numbers and need the sorted index values in descending order.

ideas?

Thanks!
0
Comment
Question by:ugeb
  • 4
  • 3
7 Comments
 
LVL 23

Expert Comment

by:tailoreddigital
ID: 39264084
I don't know a lot about Python, but ran across this, so i thought i'd toss it at you,

L2.reverse()

I grabbed this from page 17,
http://koen.me/research/teaching-asci/python-workshop-slides.pdf
0
 
LVL 11

Author Comment

by:ugeb
ID: 39264119
Thanks, but that has nothing to do with numpy's argsort.  That's plain python but I'm using numpy's data structure.
0
 
LVL 23

Expert Comment

by:tailoreddigital
ID: 39264154
I apologise if i'm barking up the wrong tree, just trying to help,

Take a look here,
http://stackoverflow.com/questions/8445323/reverse-sort-and-argsort-in-python

This seems to be a solution.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 11

Author Comment

by:ugeb
ID: 39264167
Thanks, but I've been through all these pages already through extensive searching, and they don't address the actual issue. None of the pages I've found have answered my question.
0
 
LVL 23

Expert Comment

by:tailoreddigital
ID: 39264197
I wish i could help further but i can't. Hopefully another more qualified expert will help out.

Good luck.
0
 
LVL 11

Accepted Solution

by:
ugeb earned 0 total points
ID: 39264280
Thanks anyway.  I'm having to take the longer path of converting to a list and then reversing, instead of the far more efficient path of argsort actually having a reverse argument!  Oh well.
0
 
LVL 11

Author Closing Comment

by:ugeb
ID: 39274201
Thanks anyway.  I'm having to take the longer path of converting to a list and then reversing, instead of the far more efficient path of argsort actually having a reverse argument!  Oh well.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
None is returned 6 40
Python threading 1 69
Python 2.7 - Save to file 4 51
Turning python script into an applet 12 104
A set of related code is known to be a Module, it helps us to organize our code logically which is much easier for us to understand and use it. Module is an object with arbitrarily named attributes which can be used in binding and referencing. …
The purpose of this article is to demonstrate how we can use conditional statements using Python.
Learn the basics of modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now