-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG-Fix: AssertionError when slicing MultiIndex and setting value of … #35018
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
Conversation
@dsaxton, please, can you watch it. I looked in more detail. In variables, |
I'm not very familiar with this part of the code base so take my advice with a grain of salt, but as far as I can tell start_slice and end_slice should be scalars so we don't want to just remove these assertions as you're doing here. I would instead look upstream of this to figure out why this is happening (it does seem that the Index is mangled by the time we get here and is no longer a MultiIndex, if that's any clue). |
@dsaxton, I rolled back the changes and took your advice into account. You can view? |
pandas/tests/indexing/test_loc.py
Outdated
dt2 = pd.Series(answer, index=index) | ||
|
||
dt1.loc[("baz", "one"):("foo", "two")] = 100 | ||
tm.assert_series_equal(dt1, dt2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can u do
result =
expected =
pandas/core/indexes/multi.py
Outdated
) | ||
step = start.step | ||
if isinstance(key.start, tuple) or isinstance(key.stop, tuple): | ||
return convert_indexer(key.start, key.stop, key.step) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rather than returning should not just do
start = key.start
stop = key.stop
and fall thru?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't quite understand what you mean here. Could you please explain?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add those 2 lines, then you don't need this if else.
@luckydenis can you address comments and add a release note |
@luckydenis can you address @jreback comment #35018 (comment) |
Closing as stale |
git diff upstream/master -u -- "*.py" | flake8 --diff