-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Introduction of RangeIndex #9961
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
…t64Index tests to be RangeIndex tests instead)
…he ndarray interface
…e filled...shocker)
almost all testing is now done in test_index.py |
@jreback Thanks. I am currently rewriting the test suite of Clearly instantiation will be different. Which of the following cases should be possible?
Should |
I would not trouble yourself with allowing for non-integer or missing |
# could *replace* itself on its parent. (tradeoff between instantiation time and | ||
# ability to gc values when they aren't needed anymore) | ||
# TODO: Block setting of start and end | ||
def __new__(cls, left, right=None, step=1, name=None): |
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 would follow the signature of the builtin range here:
class range(stop, *, name=None)
class range(start, stop, step=1, *, name=None)
You'll need to parse args
and kwargs
manually to make this work.
For implementation, I would strongly recommend keeping track of builtin |
I find that I frequently have to check whether the supplied dtype parameter it equivalent to
Is there a converter function already available for use in the idiom @shoyer Thanks for the helpful advice and references. |
this should use virtually the same |
Ok, I am slowly making progress: I finally figured out how to do an "analytic" intersection (inner join) between two general, dissimilar Now I am a bit unsure on how to proceed with the union (outer join) of two One could imagine a I was planning to avoid converting What does everybody think? Is it worth the effort? Or shall I just convert to a |
I would just covert to Int64Index when necessary, possibly even for all union operations on RangeIndex objects (for the sake of consistency). |
RangeIndex(1, 10, 2) is a memory saving alternative to Index(np.arange(1, 10,2)). This implementation is compatible with the current Index() api and is a drop-in replacement for Int64Index(). It automatically converts to Int64Index() when required by operations.
I am closing this in favor of #9977 to deal with merging issues. |
RangeIndex(1, 10, 2)
is a memory saving alternative toIndex(np.arange(1, 10,2))
: c.f. #939.This re-implementation is compatible with the current
Index()
api and is a drop-in replacement forInt64Index()
. It automatically converts to Int64Index() when required by operations.At present only for a minimum number of operations the type is conserved (e.g. slicing, inner-, left- and right-joins). Most other operations trigger creation of an equivalent Int64Index (or at least an equivalent numpy array) and fall back to its implementation.
This PR also extends the functionality of the
Index()
constructor to allow creation ofRangeIndexes()
within analogy to