Skip to content

Commit

Permalink
use np.asarray for threshold
Browse files Browse the repository at this point in the history
  • Loading branch information
yl2526 committed Jun 2, 2017
1 parent 8568044 commit 4434475
Showing 1 changed file with 3 additions and 14 deletions.
17 changes: 3 additions & 14 deletions pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -4412,20 +4412,9 @@ def _clip_with_one_bound(self, threshold, method, axis, inplace):
subset = method(threshold, axis=axis) | isnull(self)

# GH #15390
if is_scalar(threshold):
return self.where(subset, threshold, axis=axis, inplace=inplace)

# For arry_like threshold, convet it to Series with corret index
# `where` takes scalar, NDFrame, or callable for argument "other"
try:
if isinstance(subset, ABCSeries):
threshold = pd.Series(threshold, index=subset.index)
elif axis == 0:
threshold = pd.Series(threshold, index=subset.index)
else:
threshold = pd.Series(threshold, index=subset.columns)
finally:
return self.where(subset, threshold, axis=axis, inplace=inplace)
if (not isinstance(threshold, ABCSeries)) and is_list_like(threshold):
threshold = np.asarray(threshold)
return self.where(subset, threshold, axis=axis, inplace=inplace)

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

0 comments on commit 4434475

Please sign in to comment.