Skip to content

Commit 0084f77

Browse files
Backport PR #54823 on branch 2.1.x (REGR: clip raising for list-bound) (#54829)
Backport PR #54823: REGR: clip raising for list-bound Co-authored-by: Patrick Hoefler <[email protected]>
1 parent 68b64b8 commit 0084f77

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

pandas/core/frame.py

+1
Original file line numberDiff line numberDiff line change
@@ -7929,6 +7929,7 @@ def to_series(right):
79297929
)
79307930
elif isinstance(right, Series):
79317931
# axis=1 is default for DataFrame-with-Series op
7932+
axis = axis if axis is not None else 1
79327933
if not flex:
79337934
if not left.axes[axis].equals(right.index):
79347935
raise ValueError(

pandas/tests/frame/methods/test_clip.py

+11
Original file line numberDiff line numberDiff line change
@@ -177,3 +177,14 @@ def test_clip_int_data_with_float_bound(self):
177177
result = df.clip(lower=1.5)
178178
expected = DataFrame({"a": [1.5, 2.0, 3.0]})
179179
tm.assert_frame_equal(result, expected)
180+
181+
def test_clip_with_list_bound(self):
182+
# GH#54817
183+
df = DataFrame([1, 5])
184+
expected = DataFrame([3, 5])
185+
result = df.clip([3])
186+
tm.assert_frame_equal(result, expected)
187+
188+
expected = DataFrame([1, 3])
189+
result = df.clip(upper=[3])
190+
tm.assert_frame_equal(result, expected)

0 commit comments

Comments
 (0)