diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 5e41bc6ec9481..fe7ca6fa5c9b1 100755 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -1776,7 +1776,7 @@ def __getitem__(self, key): return self._getitem_multilevel(key) elif isinstance(key, DataFrame): if key.values.dtype == bool: - return self.mask(key) + return self.where(key) else: raise ValueError('Cannot index using non-boolean DataFrame') else: @@ -4867,7 +4867,7 @@ def combineMult(self, other): """ return self.mul(other, fill_value=1.) - def where(self, cond, other, inplace=False): + def where(self, cond, other=NA, inplace=False): """ Return a DataFrame with the same shape as self and whose corresponding entries are from self where cond is True and otherwise are from other. @@ -4901,21 +4901,6 @@ def where(self, cond, other, inplace=False): rs = np.where(cond, self, other) return self._constructor(rs, self.index, self.columns) - def mask(self, cond): - """ - Returns copy of self whose values are replaced with nan if the - corresponding entry in cond is False - - Parameters - ---------- - cond: boolean DataFrame or array - - Returns - ------- - wh: DataFrame - """ - return self.where(cond, NA) - _EMPTY_SERIES = Series([]) diff --git a/pandas/tests/test_frame.py b/pandas/tests/test_frame.py index ef4e557b8e3a8..aec7ddffd84e4 100755 --- a/pandas/tests/test_frame.py +++ b/pandas/tests/test_frame.py @@ -142,7 +142,6 @@ def test_getitem_boolean(self): self.assertRaises(ValueError, self.tsframe.__getitem__, self.tsframe) # test df[df >0] works - bif = self.tsframe[self.tsframe > 0] bifw = DataFrame(np.where(self.tsframe>0,self.tsframe,np.nan),index=self.tsframe.index,columns=self.tsframe.columns) self.assert_(isinstance(bif,DataFrame)) @@ -5215,8 +5214,6 @@ def test_where(self): for k, v in rs.iteritems(): assert_series_equal(v, np.where(cond[k], df[k], other5)) - assert_frame_equal(rs, df.mask(cond)) - err1 = (df + 1).values[0:2, :] self.assertRaises(ValueError, df.where, cond, err1)