Skip to content
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

Merged
merged 7 commits into from
Dec 28, 2018
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -7172,7 +7172,7 @@ def _clip_with_one_bound(self, threshold, method, axis, inplace):
if isinstance(self, ABCSeries):
threshold = pd.Series(threshold, index=self.index)
else:
threshold = _align_method_FRAME(self, np.asarray(threshold),
threshold = _align_method_FRAME(self, threshold,
axis)
return self.where(subset, threshold, axis=axis, inplace=inplace)

Expand Down
8 changes: 8 additions & 0 deletions pandas/tests/frame/test_analytics.py
Original file line number Diff line number Diff line change
Expand Up @@ -1965,6 +1965,14 @@ def test_clip_against_frame(self, axis):
tm.assert_frame_equal(clipped_df[ub_mask], ub[ub_mask])
tm.assert_frame_equal(clipped_df[mask], df[mask])

def test_clip_against_unordered_columns(self):
# 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)
Copy link
Contributor

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

expected = df1.clip(lower=0, upper=df2[df1.columns])
tm.assert_frame_equal(result, expected)

def test_clip_with_na_args(self, float_frame):
"""Should process np.nan argument as None """
# GH 17276
Expand Down