-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
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
added option keep=False to nlargests/nsmallest #18656
Conversation
Closed due to decision in #18559. |
actually this is prob reasonable. |
Codecov Report
@@ Coverage Diff @@
## master #18656 +/- ##
==========================================
- Coverage 91.59% 91.57% -0.02%
==========================================
Files 153 153
Lines 51221 51223 +2
==========================================
- Hits 46917 46910 -7
- Misses 4304 4313 +9
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #18656 +/- ##
==========================================
- Coverage 91.61% 91.6% -0.02%
==========================================
Files 153 153
Lines 51367 51369 +2
==========================================
- Hits 47061 47056 -5
- Misses 4306 4313 +7
Continue to review full report at Codecov.
|
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.
change the whatsnew note which remove the keep=False
(but keep the actual issue number attached there)
pandas/tests/frame/test_analytics.py
Outdated
@@ -2162,6 +2162,21 @@ def test_n_duplicate_index(self, df_duplicates, n, order): | |||
expected = df.sort_values(order, ascending=False).head(n) | |||
tm.assert_frame_equal(result, expected) | |||
|
|||
def test_keep_false(self): | |||
df = pd.DataFrame({'a': [5, 4, 4, 2, 3, 3, 3, 3], |
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 the issue number here
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.
make a more informative name for the test
@@ -1865,3 +1865,14 @@ def test_n(self, n): | |||
result = s.nsmallest(n) | |||
expected = s.sort_values().head(n) | |||
assert_series_equal(result, expected) | |||
|
|||
def test_keep_false(self): | |||
s = Series([10, 9, 8, 7, 7, 7, 7, 6]) |
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.
same as above
@@ -910,8 +910,8 @@ def __init__(self, obj, n, keep): | |||
self.n = n | |||
self.keep = keep | |||
|
|||
if self.keep not in ('first', 'last'): |
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.
need to add back to the docs-string (don't need a version added as it was tehre before)
yeah |
@jreback Changes complete. Also, I didn't see anything in whatsnew on the other issues. |
pls rebase |
closing as stale |
git diff upstream/master -u -- "*.py" | flake8 --diff
I made a minor change to
nlargest/nsmallest
to keep all the values of the lastn
whenkeep=False