8000 Include MultiIndex slice in non-reducing slices by fleimgruber · Pull Request #19881 · pandas-dev/pandas · GitHub
[go: up one dir, main page]

Skip to content

Include MultiIndex slice in non-reducing slices #19881

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 4 commits into from
Jan 2, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Update comments and parenthesis for if condition
  • Loading branch information
fleimgruber committed Jan 2, 2019
commit a00dd9e37339a0741a5d9ebc60420d7fb6a04542
4 changes: 2 additions & 2 deletions pandas/core/indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -2734,8 +2734,8 @@ def _non_reducing_slice(slice_):
def pred(part):
# true when slice does *not* reduce, False when part is a tuple,
# i.e. MultiIndex slice
return (isinstance(part, slice) or is_list_like(part))\
and not isinstance(part, tuple)
return ((isinstance(part, slice) or is_list_like(part))
and not isinstance(part, tuple))

if not is_list_like(slice_):
if not isinstance(slice_, slice):
Expand Down
1 change: 1 addition & 0 deletions pandas/tests/indexing/test_indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -813,6 +813,7 @@ def test_non_reducing_slice(self):
assert isinstance(df.loc[tslice_], DataFrame)

def test_non_reducing_slice_on_multiindex(self):
# GH 19861
dic = {
('a', 'd'): [1, 4],
('a', 'c'): [2, 3],
Expand Down
3 changes: 2 additions & 1 deletion pandas/tests/io/formats/test_style.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,8 @@ def f(x):
assert result == expected

def test_applymap_subset_multiindex(self):
# https://github.com/pandas-dev/pandas/issues/19861
# GH 19861
# Smoke test for applymap
def color_negative_red(val):
"""
Takes a scalar and returns a string with
Expand Down
0