-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
MultiIndex names attribute broken when using set_value() to expand DataFrame() #3742
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
marked as bug for 0.12 |
closing in favor of #4039 . will move example from here to there |
Thanks for fixing this, people. I love Pandas! |
FYI: Issue was that |
jtratner
added a commit
to jtratner/pandas
that referenced
this issue
Aug 11, 2013
* `names` is now a property *and* is set up as an immutable tuple. * `levels` are always (shallow) copied now and it is deprecated to set directly * `labels` are set up as a property now, moving all the processing of labels out of `__new__` + shallow-copied. * `levels` and `labels` are immutable. * Add names tests, motivating example from pandas-dev#3742, reflect tuple-ish output from names, and level names check to reindex test. * Add set_levels, set_labels, set_names and rename to index * Deprecate setting labels and levels directly Similar to other set_* methods...allows mutation if necessary but otherwise returns same object. Labels are now converted to `FrozenNDArray` and wrapped in a `FrozenList`. Should mostly resolve pandas-dev#3714 because you have to work to actually make assignments to an `Index`. BUG: Give MultiIndex its own astype method Fixes issue with set_value forgetting names.
jreback
pushed a commit
that referenced
this issue
Aug 12, 2013
* `names` is now a property *and* is set up as an immutable tuple. * `levels` are always (shallow) copied now and it is deprecated to set directly * `labels` are set up as a property now, moving all the processing of labels out of `__new__` + shallow-copied. * `levels` and `labels` are immutable. * Add names tests, motivating example from #3742, reflect tuple-ish output from names, and level names check to reindex test. * Add set_levels, set_labels, set_names and rename to index * Deprecate setting labels and levels directly Similar to other set_* methods...allows mutation if necessary but otherwise returns same object. Labels are now converted to `FrozenNDArray` and wrapped in a `FrozenList`. Should mostly resolve #3714 because you have to work to actually make assignments to an `Index`. BUG: Give MultiIndex its own astype method Fixes issue with set_value forgetting names.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have raised the issue in this question on Stack Overflow, but I'm not sure it ever made it to the Pandas issue tracker.
I have a MultiIndex'ed DataFrame which I want to expand by using
set_value()
, but doing this destroys thenames
attribute of the index. This does not happen when setting the value of an already existing entry in the DataFrame. An easily reproducible example is to create the dataframe by:This shows a neat and nice object, just as I expected, with proper naming of the index columns. If I now run:
the result is also as expected. But if I run:
The column names of the index are gone, and the
names
attribute has been set to[None, None]
.The text was updated successfully, but these errors were encountered: