-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: reset_index can reset index name #17067
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
Comments
@p-himik : Thanks for the issue! Indeed this is a bug, for the documentation says the following: "For a standard index, the index name will be used (if set), otherwise a default ‘index’ or ‘level_0’ (if ‘index’ is already taken) will be used." Here's a similar bug that should also be pointed out: s = pd.Series([1, 2, 3])
s.index.name = "foo"
s.index += 1
assert s.index.name == "foo" The index name magically disappears like in your example (probably linked to the code you pointed out). PR is welcome to patch these issues! |
I would like to working on this issue. |
The original assertion is already true in master. I think the issue is that |
Then should I remove the test case?
2017. 8. 18. 오전 9:51 Jeff Reback <[email protected]> 작성:
… In [16]: pd.DataFrame(index=pd.Index([], name='x')).reset_index(level=[]).index.name is None
Out[16]: True
In [17]: pd.__version__
Out[17]: '0.21.0.dev+371.g0ee1675'
The original assertion is already true in master. I think the issue is that level=[] is actually an invalid specification.
@chris-b1 @jorisvandenbossche
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
Hello, is this issue still open for a fix? IMHO, reset_index without an index name is not necessarily a bad thing. Do we actually want to keep index name during reset_index()? |
it appears this issue has already been fixed. perhaps can be closed? |
It would be good to still add a test to assert this keeps working |
@jorisvandenbossche : Indeed! That's what @minggli is trying to do in the now-reopened #23116. |
The root of the problem is in
pandas.core.common._default_index
:Probably, a new optional argument
name
can be introduced to_default_index
and used inreset_index
.The text was updated successfully, but these errors were encountered: