-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
BUG: raise on RangeIndex.array #40022
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
yes please as we already special case MI there. |
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.
yeah let's fold this into extract_array
This can and should go through a deprecation warning IMO. |
Agreed. In addition, are we sure that we actually want to raise an error? Eg (the public |
Agreed.
The only strong opinion i have on this is that RangeIndex behavior should match MultiIndex behavior. |
I'm not sure. I think it's surprising that |
There are many operations on RangeIndex that do allocate memory though. For me, I see RangeIndex a bit like Int64Index but without materializing "as long as possible". And when asking for its array representation, it is no longer possible.
@jbrockmendel Can you explain why you want this? A practical reason? Or conceptually since both are not directly backed by a single array? (on which I would say: that's true, but RangeIndex still "represents" a single array, while MultiIndex does not. So I think there are also reasons to give them different behaviour) |
id like to see this. among other things it would allows set_index(rangecol).reset_index() to round-trip nicely
(At least until there is a RangeArray) RangeIndex doesn't represent a single array. As you mentioned above, it has (I actually dont like the .array property in most cases, pretty much always find ._values more useful) I am more concerned with |
Yes, as mentioned above, IMO the two don't necessarily need to do the same. I certainly follow that
The
Let's open a separate issue to discuss this if people would like to see this. |
Co-authored-by: Joris Van den Bossche <[email protected]>
Hello @jbrockmendel! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found: There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻 Comment last updated at 2021-04-07 17:00:09 UTC |
Should be ready for another look |
Apart from #40022 (comment), not further comments from my side |
can you merge master. i will look at this soon. |
rebased + greenish |
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 you rebase one more time, ping on green
@@ -367,9 +370,12 @@ def nargsort( | |||
mask=mask, | |||
) | |||
|
|||
items = extract_array(items) | |||
if isinstance(items, ABCRangeIndex): | |||
return items.argsort(ascending=ascending) # TODO: test coverage with key? |
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.
hmm if you use extract_range on L376 i think you can just fall thru no? (or I guess need L380 to change), anyhow for the future
also do you need a whatnew? e.g. what exactly is the bug |
there shouldnt be anything user-facing |
xerf #37277 cc @TomAugspurger this is failing one of the dask tests locally, looks like dask is calling
index.array
. Thoughts on how to handle this?Might be worth folding the RangeIndex check into a keyword in extract_array.