-
-
Notifications
You must be signed in to change notification settings - Fork 18.2k
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
Bug : Fixes #20911 #24467
Bug : Fixes #20911 #24467
Conversation
Passing threshold as it is instead of numpy array to preserve the columns order.
Additional test cases to validate the fix
Hello @cgangwar11! Thanks for updating the PR. Cheers ! There are no PEP8 issues in this Pull Request. 🍻 Comment last updated on December 28, 2018 at 22:56 Hours UTC |
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.
pls add a whatsnew note
pandas/tests/frame/test_analytics.py
Outdated
@@ -1964,6 +1964,13 @@ def test_clip_against_frame(self, axis): | |||
tm.assert_frame_equal(clipped_df[lb_mask], lb[lb_mask]) | |||
tm.assert_frame_equal(clipped_df[ub_mask], ub[ub_mask]) | |||
tm.assert_frame_equal(clipped_df[mask], df[mask]) | |||
# GH 20911, clipping now preserves types |
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 this a new test
pandas/tests/frame/test_analytics.py
Outdated
@@ -1964,6 +1964,13 @@ def test_clip_against_frame(self, axis): | |||
tm.assert_frame_equal(clipped_df[lb_mask], lb[lb_mask]) | |||
tm.assert_frame_equal(clipped_df[ub_mask], ub[ub_mask]) | |||
tm.assert_frame_equal(clipped_df[mask], df[mask]) | |||
# GH 20911, clipping now preserves types | |||
df1 = DataFrame(np.random.randn(1000,4), columns=['A', 'B','C','D']) | |||
df2 = DataFrame(np.random.randn(1000,4), columns=['D', 'A','B','C']) |
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.
you have some lint errors.
pandas/tests/frame/test_analytics.py
Outdated
df1 = DataFrame(np.random.randn(1000,4), columns=['A', 'B','C','D']) | ||
df2 = DataFrame(np.random.randn(1000,4), columns=['D', 'A','B','C']) | ||
|
||
res1 = df1.clip(lower=0,upper=df2) |
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.
use result= and expected=
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.
will do pardon me for such a rookie mistake....
Codecov Report
@@ Coverage Diff @@
## master #24467 +/- ##
=======================================
Coverage 92.3% 92.3%
=======================================
Files 163 163
Lines 51969 51969
=======================================
Hits 47968 47968
Misses 4001 4001
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #24467 +/- ##
==========================================
- Coverage 92.31% 92.31% -0.01%
==========================================
Files 165 165
Lines 52252 52204 -48
==========================================
- Hits 48237 48192 -45
+ Misses 4015 4012 -3
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.
pls add a whatsnew entry
pandas/tests/frame/test_analytics.py
Outdated
# GH 20911 | ||
df1 = DataFrame(np.random.randn(1000, 4), columns=['A', 'B', 'C', 'D']) | ||
df2 = DataFrame(np.random.randn(1000, 4), columns=['D', 'A', 'B', 'C']) | ||
result = df1.clip(lower=0, upper=df2) |
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 try this with lower as well
lgtm ping on green |
Better ExampleBefore` In [11]: import pandas as pd
...:
...: df1 = pd.DataFrame([[50., 60.,70.], [80., 90.,100.]], columns=['A', 'B','C'])
...:
...: upper = pd.DataFrame([[50., 80.,49.], [100.,100.,90.]], columns=['B', 'C','A'])
...:
...: lower = pd.DataFrame([[60., 40.,35.], [90.,95.,85.]], columns=['C', 'B','A'])
...:
...:
In [12]: df1
Out[12]:
A B C
0 50.0 60.0 70.0
1 80.0 90.0 100.0
In [16]: lower[df1.columns]
Out[16]:
A B C
0 35.0 40.0 60.0
1 85.0 95.0 90.0
In [17]: upper[df1.columns]
Out[17]:
A B C
0 49.0 50.0 80.0
1 90.0 100.0 100.0
In [18]: df1.clip(lower=lower,upper=upper)
Out[18]:
A B C
0 50.0 80.0 70.0
1 90.0 95.0 100.0 After In [8]: (df1.clip(lower=lower, upper=upper))
Out[8]:
A B C
0 49.0 50.0 70.0
1 85.0 95.0 100.0 |
@jreback it's green now |
thanks @cgangwar11 |
git diff upstream/master -u -- "*.py" | flake8 --diff
Before
After