Skip to content

Commit 8034116

Browse files
committed
in core/frame.py
removed mask method made other optional kw parm in where changed __setitem__ to use where (rather than mask)
1 parent 030bc66 commit 8034116

File tree

2 files changed

+2
-20
lines changed

2 files changed

+2
-20
lines changed

pandas/core/frame.py

+2-17
Original file line numberDiff line numberDiff line change
@@ -1776,7 +1776,7 @@ def __getitem__(self, key):
17761776
return self._getitem_multilevel(key)
17771777
elif isinstance(key, DataFrame):
17781778
if key.values.dtype == bool:
1779-
return self.mask(key)
1779+
return self.where(key)
17801780
else:
17811781
raise ValueError('Cannot index using non-boolean DataFrame')
17821782
else:
@@ -4867,7 +4867,7 @@ def combineMult(self, other):
48674867
"""
48684868
return self.mul(other, fill_value=1.)
48694869

4870-
def where(self, cond, other, inplace=False):
4870+
def where(self, cond, other=NA, inplace=False):
48714871
"""
48724872
Return a DataFrame with the same shape as self and whose corresponding
48734873
entries are from self where cond is True and otherwise are from other.
@@ -4901,21 +4901,6 @@ def where(self, cond, other, inplace=False):
49014901
rs = np.where(cond, self, other)
49024902
return self._constructor(rs, self.index, self.columns)
49034903

4904-
def mask(self, cond):
4905-
"""
4906-
Returns copy of self whose values are replaced with nan if the
4907-
corresponding entry in cond is False
4908-
4909-
Parameters
4910-
----------
4911-
cond: boolean DataFrame or array
4912-
4913-
Returns
4914-
-------
4915-
wh: DataFrame
4916-
"""
4917-
return self.where(cond, NA)
4918-
49194904
_EMPTY_SERIES = Series([])
49204905

49214906

pandas/tests/test_frame.py

-3
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,6 @@ def test_getitem_boolean(self):
142142
self.assertRaises(ValueError, self.tsframe.__getitem__, self.tsframe)
143143

144144
# test df[df >0] works
145-
146145
bif = self.tsframe[self.tsframe > 0]
147146
bifw = DataFrame(np.where(self.tsframe>0,self.tsframe,np.nan),index=self.tsframe.index,columns=self.tsframe.columns)
148147
self.assert_(isinstance(bif,DataFrame))
@@ -5215,8 +5214,6 @@ def test_where(self):
52155214
for k, v in rs.iteritems():
52165215
assert_series_equal(v, np.where(cond[k], df[k], other5))
52175216

5218-
assert_frame_equal(rs, df.mask(cond))
5219-
52205217
err1 = (df + 1).values[0:2, :]
52215218
self.assertRaises(ValueError, df.where, cond, err1)
52225219

0 commit comments

Comments
 (0)