Skip to content

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

Closed
wants to merge 4 commits into from
Closed

Conversation

luckydenis
Copy link
Contributor

@luckydenis
Copy link
Contributor Author

@dsaxton, please, can you watch it. I looked in more detail. In variables, start_slice and end_slice are lists with coordinates. Therefore, we get an error when checking for a scalar. Having studied the code, I did not find the reasons why we cannot process them.

@dsaxton
Copy link
Member

dsaxton commented Jul 1, 2020

@dsaxton, please, can you watch it. I looked in more detail. In variables, start_slice and end_slice are lists with coordinates. Therefore, we get an error when checking for a scalar. Having studied the code, I did not find the reasons why we cannot process them.

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).

@luckydenis
Copy link
Contributor Author

@dsaxton, I rolled back the changes and took your advice into account. You can view?

dt2 = pd.Series(answer, index=index)

dt1.loc[("baz", "one"):("foo", "two")] = 100
tm.assert_series_equal(dt1, dt2)
Copy link
Contributor

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 =

)
step = start.step
if isinstance(key.start, tuple) or isinstance(key.stop, tuple):
return convert_indexer(key.start, key.stop, key.step)
Copy link
Contributor

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?

Copy link
Contributor Author

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?

Copy link
Contributor

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.

@simonjayhawkins
Copy link
Member

@luckydenis can you address comments and add a release note

@jreback jreback added Bug Indexing Related to indexing on series/frames, not to indexes themselves MultiIndex labels Aug 13, 2020
@simonjayhawkins
Copy link
Member

@luckydenis can you address @jreback comment #35018 (comment)

@github-actions github-actions bot removed the Stale label Sep 20, 2020
@dsaxton dsaxton added the Stale label Sep 20, 2020
@dsaxton
Copy link
Member

dsaxton commented Sep 22, 2020

Closing as stale

@dsaxton dsaxton closed this Sep 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Indexing Related to indexing on series/frames, not to indexes themselves MultiIndex Stale
Projects
None yet
Development

Successfully merging this pull request may close these issues.

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