Skip to content

Commit e54ca22

Browse files
yl2526jreback
authored andcommitted
use np.asarray for threshold
1 parent 7b52f5f commit e54ca22

File tree

1 file changed

+3
-14
lines changed

1 file changed

+3
-14
lines changed

pandas/core/generic.py

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4429,20 +4429,9 @@ def _clip_with_one_bound(self, threshold, method, axis, inplace):
44294429
subset = method(threshold, axis=axis) | isnull(self)
44304430

44314431
# GH #15390
4432-
if is_scalar(threshold):
4433-
return self.where(subset, threshold, axis=axis, inplace=inplace)
4434-
4435-
# For arry_like threshold, convet it to Series with corret index
4436-
# `where` takes scalar, NDFrame, or callable for argument "other"
4437-
try:
4438-
if isinstance(subset, ABCSeries):
4439-
threshold = pd.Series(threshold, index=subset.index)
4440-
elif axis == 0:
4441-
threshold = pd.Series(threshold, index=subset.index)
4442-
else:
4443-
threshold = pd.Series(threshold, index=subset.columns)
4444-
finally:
4445-
return self.where(subset, threshold, axis=axis, inplace=inplace)
4432+
if (not isinstance(threshold, ABCSeries)) and is_list_like(threshold):
4433+
threshold = np.asarray(threshold)
4434+
return self.where(subset, threshold, axis=axis, inplace=inplace)
44464435

44474436
def clip(self, lower=None, upper=None, axis=None, inplace=False,
44484437
*args, **kwargs):

0 commit comments

Comments
 (0)