-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
DOC: add nlargest/nsmallest to API.rst #10145
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
http://pandas.pydata.org/pandas-docs/stable/basics.html?highlight=nlargest#smallest-largest-values (this is even faster than though these are not mentioned in API.rst. want to do a PR to add them? |
Ok, but this one is for Series, my issue was about getting top N rows from DataFrame ordered by columns I want, similar to SQL |
df.apply(Series.nlargest) |
Thanks again, but it still will not work if I want to sort by several columns. As an example - suppose I have this dataset:
And I want to take top 4 records ordered by |
I don't think there is an easy way to do this w/o a full-sort. |
At the moment there's no easy way to partially sort the DataFrame to get top N rows, could be useful feature.
There's partial sorting available for numpy within the bottleneck library.
Here's link to SO question about numpy partial sort - http://stackoverflow.com/questions/10337533/a-fast-way-to-find-the-largest-n-elements-in-an-numpy-array
The text was updated successfully, but these errors were encountered: