-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
BUG: GH12071 .reset_index() should create a RangeIndex #12080
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
Fixes #12071 |
@@ -2891,7 +2891,10 @@ def _maybe_casted_values(index, labels=None): | |||
np.nan) | |||
return values | |||
|
|||
new_index = np.arange(len(new_obj), dtype='int64') |
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.
just use core.common._default_index
instead here
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.
this can always be _default_index
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 changed it and squashed it into the same commit
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.
new_index = _default_index(len(new_obj))
is the entire answer here, you don't need a separate check whether its a RangeIndex
or not
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.
Fixed
add this issue number to right after #939 in |
64018c2
to
d46a550
Compare
Thanks. Updated the pull request. Not sure if I put the reference to the issue in the right place in "whatsnew" (this is my first PR to pandas). |
add a test for Series as well |
d46a550
to
99e48e9
Compare
index=RangeIndex(stop=2)) | ||
assert_frame_equal(result, expected) | ||
|
||
s = pd.Series(range(2), name='A', index=RangeIndex(stop=2)) |
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.
Test for Series Added
99e48e9
to
11d48bf
Compare
merged via 16a7799 thanks! |
Thanks for the help @jreback |
closes #12071