Skip to content

BUG: masking empty DataFrame #11895

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 26, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/source/whatsnew/v0.18.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -345,3 +345,4 @@ Bug Fixes

- Bug in ``read_sql`` with pymysql connections failing to return chunked data (:issue:`11522`)

- Bug in ``DataFrame`` when masking an empty ``DataFrame`` (:issue:`11859`)
2 changes: 1 addition & 1 deletion pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -2047,7 +2047,7 @@ def _getitem_multilevel(self, key):
return self._get_item_cache(key)

def _getitem_frame(self, key):
if key.values.dtype != np.bool_:
if key.values.size and not com.is_bool_dtype(key.values):
raise ValueError('Must pass DataFrame with boolean values only')
return self.where(key)

Expand Down
7 changes: 7 additions & 0 deletions pandas/tests/test_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -826,6 +826,13 @@ def test_setitem_empty_frame_with_boolean(self):
df[df > df2] = 47
assert_frame_equal(df, df2)

def test_getitem_empty_frame_with_boolean(self):
# Test for issue #11859

df = pd.DataFrame()
df2 = df[df>0]
assert_frame_equal(df, df2)

def test_delitem_corner(self):
f = self.frame.copy()
del f['D']
Expand Down