Skip to content

Commit

Permalink
REGR: clip raising for list-bound (pandas-dev#54823)
Browse files Browse the repository at this point in the history
  • Loading branch information
phofl authored Aug 28, 2023
1 parent 3e1a9d0 commit ad0eb14
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -7948,6 +7948,7 @@ def to_series(right):
)
elif isinstance(right, Series):
# axis=1 is default for DataFrame-with-Series op
axis = axis if axis is not None else 1
if not flex:
if not left.axes[axis].equals(right.index):
raise ValueError(
Expand Down
11 changes: 11 additions & 0 deletions pandas/tests/frame/methods/test_clip.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,3 +177,14 @@ def test_clip_int_data_with_float_bound(self):
result = df.clip(lower=1.5)
expected = DataFrame({"a": [1.5, 2.0, 3.0]})
tm.assert_frame_equal(result, expected)

def test_clip_with_list_bound(self):
# GH#54817
df = DataFrame([1, 5])
expected = DataFrame([3, 5])
result = df.clip([3])
tm.assert_frame_equal(result, expected)

expected = DataFrame([1, 3])
result = df.clip(upper=[3])
tm.assert_frame_equal(result, expected)

0 comments on commit ad0eb14

Please sign in to comment.