-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
ENH: add nlargest nsmallest to Series #7113
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
Conversation
@@ -1762,7 +1770,17 @@ def _try_kind_sort(arr): | |||
good = ~bad | |||
idx = pa.arange(len(self)) | |||
|
|||
argsorted = _try_kind_sort(arr[good]) | |||
def _try_kind_sort(arr, kind='mergesort'): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
crap this is screwed up ...i chose the wrong thing in the merge conflict
@@ -128,6 +128,7 @@ API changes | |||
import pandas.core.common as com | |||
com.array_equivalent(np.array([0, np.nan]), np.array([0, np.nan])) | |||
np.array_equal(np.array([0, np.nan]), np.array([0, np.nan])) | |||
- Add nsmallest and nlargest Series methods (:issue:`3960`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move this to 0.14.0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep thanks
and pls do a vbench to verify these don't really change anything else I think @hayd had an optimization for these methods somewhere, but push that off to another version (and they may be fine anyhow) |
sure thing |
there was discussion of |
that's cool..fine with the names |
vbench
i was running some other things at the same time ... @jreback are these okay? |
yep |
Parameters | ||
---------- | ||
n : int, optional, default: ``5`` | ||
take_last : bool, optional, default: ``False`` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add an explanation of the take_last
parameter?
Also please follow the format:
kwarg : type
Explanation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep wasn't finished with docstrings yet, thx for pointing this out
@jreback @jorisvandenbossche any more comments? will squash and then can merge |
g2g |
@cpcloud pls squash down a bit and looks good 2 go |
maybe a small doc mention here? http://pandas-docs.github.io/pandas-docs-travis/basics.html#sorting-by-index-and-value |
@jreback doc and squish ok? |
yep go 4 it |
ENH: add nlargest nsmallest to Series
seems some of the complex dtypes don't exist on some arch's (windows even though this is 2.7-64 bit). so need to test that numpy can create before testing that they raise.
|
or could just totally skip the complex256 I think (easier) |
easy enough just to take it out: 1533480 |
ok sorry about this ... i'll take it out since 128 is enough... really just there to test that the dtype check in select_n fails for the types that cannot be "sanely" sorted |
oh i see... you've already done it |
thanks! |
@cpcloud thanks for picking up the ball here! |
@hayd absolutely np! |
ha! graphlab call this topk. |
closes #3960
xref: #5534