Skip to content

Commit 930c140

Browse files
committed
BUG: Series.where always inplace
1 parent 6876c17 commit 930c140

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

pandas/core/series.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -585,8 +585,8 @@ def where(self, cond, other=nan, inplace=False):
585585

586586
ser = self if inplace else self.copy()
587587
if not isinstance(other, (list, tuple, np.ndarray)):
588-
self._set_with(~cond, other)
589-
return self
588+
ser._set_with(~cond, other)
589+
return ser
590590

591591
if isinstance(other, Series):
592592
other = other.reindex(ser.index)

pandas/tests/test_series.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -952,6 +952,7 @@ def test_where(self):
952952

953953
rs = s.where(cond)
954954
assert(s.shape == rs.shape)
955+
assert(rs is not s)
955956

956957
rs = s.where(cond[:3], -s)
957958
assert_series_equal(rs, s.abs()[:3].append(s[3:]))

0 commit comments

Comments
 (0)