Skip to content
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: set_index drops index name #6452

Closed
jseabold opened this issue Feb 23, 2014 · 2 comments · Fixed by #6459
Closed

ENH: set_index drops index name #6452

jseabold opened this issue Feb 23, 2014 · 2 comments · Fixed by #6459

Comments

@jseabold
Copy link
Contributor

Index

df = pd.util.testing.makeDataFrame()
df.index.name = 'name'
df.set_index(df.index)
df.set_index(df.index).index.names

MultiIndex

from statsmodels.datasets import grunfeld
data = sm.datasets.grunfeld.load_pandas().data
data = data.set_index(['firm', 'year'])
data.set_index(data.index).index.names

Version

[~/]
[33]: pd.version.version
[33]: '0.13.1-254-g150f323'
@jseabold
Copy link
Contributor Author

I guess I shouldn't be using set_index to do this. Use reindex. Might want to either raise an error or pass along to reindex under the hood?

@jreback
Copy link
Contributor

jreback commented Feb 23, 2014

This is technically not valid according to the doc-string, as it accepts arrays which is sufficiently ambiguous, but 'works' with Series/ndarray (and index happens to be a ndarray subclass currently). So I think this could easily work; marking as an enhancement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants