Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
ENH: NumericIndex for any numpy int/uint/float dtype #41153
ENH: NumericIndex for any numpy int/uint/float dtype #41153
Changes from all commits
9739f85
88a7858
7ccb1b7
b45500d
5ef35f5
d8f6c22
1c65a0b
f3e13aa
4e17485
c1e801d
aa0cea7
1f5f922
132ce44
058cd2e
1c7f23f
07a097c
ff6cfb4
fe7b97c
86f3960
2424c0d
a515bba
341fc2f
c2d8884
5a56b1a
a497d57
6557689
5bc4c2c
84bf540
69953b4
b4be77d
bb42e2d
bafa9b3
35b0e71
ed4730b
6a32788
47e208c
d6a03a0
ec003ed
7ddee71
2bb282f
c1633fb
9c7d57b
f6dccc1
3630fc7
bfe6895
8532ddb
186de8e
ead8f57
2a850ea
d04da70
4b8385c
1f52f8b
951c5f7
7c7c0dd
bb72c68
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
why can't this be handled in the Index constructor itself?
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.
It's the same thing as the others: The Index constructor returns Int64Index etc. in order to maintain backward compat.
When we remove Int64Index etc. in pandas 2.0, this block can be removed, see comment on line 363 regarding this.
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 annotate dtype as Dtype
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.
Ok.
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.
should we change/deprecate Index.astype(np.int32), also Index(foo, dtype=np.int32)?
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,
Index.astype(np.int32)
returning anInt64Index
is probably used internally, so a deprecation would require if/else clauses at various locations in the code base. Probably possible, but could we get this PR in first? This PR isn't public-facing, so I don't see a problem just merging this first/separately.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.
doing that as a follow-up sounds good
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.
why do you think you need this try/except? e.g. validate_dtype should raise correct?
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.
There are a lot of combinations of
data
anddtype
and it's difficult (for me) to nail down to something sensible. For example:may not give the same error or error message.
I've tried again now and can't seem to find anything clearer. I'm not so happy about it myself, but there just seems to be very difficult to improve (for me, maybe someone else can find something better).
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 c, ok, can you comment on this (as we may want to try to figure this out in the future)
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.
Ok.
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 add a "TODO" to this comment
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.
Ok.
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.
why is this needed?
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.
The super method is
Index.astype
. That method needs to assume that numeric indexes areInt64Index
etc. and notNumericIndex
in order to maintain backward compatability.So without the lines above e.g.
NumericIndex[int32].astype("int8")
would return aInt64Index
with int64 dtype , which is not what we'd want.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.
kk can you leave a comment to this effect