Skip to content

Fix - BUG: AssertionError when slicing MultiIndex and setting value o… #34973

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

Closed
wants to merge 3 commits into from
Closed

Conversation

luckydenis
Copy link
Contributor

Copy link
Member

@dsaxton dsaxton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You'll also want to add a release note for this

@@ -4947,9 +4949,9 @@ def slice_indexer(self, start=None, end=None, step=None, kind=None):
start_slice, end_slice = self.slice_locs(start, end, step=step, kind=kind)

# return a slice
if not is_scalar(start_slice):
if not is_scalar(Fraction(start_slice)):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain why we're trying to turn this into a fraction? I think this may only be working by accident since TypeErrors are getting caught upstream.

test.loc[('baz', 'one'):('foo', 'two')] = 4
correct[('baz', 'one'):('foo', 'two')] = 4

assert correct.equals(test)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explicitly construct the expected output (i.e., rather than setting with another form of indexing) and then use assert_series_equal to test this (naming the two Series result and expected)?

@luckydenis luckydenis closed this Jun 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: AssertionError when slicing MultiIndex and setting value of pandas.Series
3 participants