You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My original plan in #23167 was just to disable MultiIndex.str regardless of the number of levels, but @toobaz brought up the point (in a side discussion in #23670) that:
Sorry, naive question, but what is the problem with just running .str on the result of self.get_level_values(0)?
This would, of course, work without problem. The main question that arises from this issue:
should the .str-accessor be enabled for MultiIndex at all?
if yes, should it return an Index or a 1-level MultiIndex?
PS. As another link to #23670, one could maybe consider enabling .str for allMultiIndex, by operating on MultiIndex.to_flat_index() in those cases. This might be interesting for example for easy joining of the MultiIndex-levels with .str.join.
The text was updated successfully, but these errors were encountered:
should the .str-accessor be enabled for MultiIndex at all?
As mentioned on the other issue, I think that we need to clearly decide among one of the following policies:
Index and 1-level MultiIndex are different implementations of precisely the same thing - and so behave identically, including with the .str accessor
Index and 1-level MultiIndex are different by design because they achieve different purposes (and by "different" I don't mean "one has a subset of features of the other")
we deprecate 1-level MultiIndexes and immediately stop producing them in our code
I think there is no evidence/support for 2. So it is just a matter of understanding if 1. is feasible. I always thought it is (and it might have the advantage of avoiding some conversions), but if it is not (e.g. we do not want to implement .str for 1-level MultiIndex) then I think we should go with 3.
if yes, should it return an Index or a 1-level MultiIndex?
Assuming we follow policy 1., Index I think: simpler to implement, and I see no advantage for the alternative.
Following from #23167...
The current checks for the
.str
-constructor regardingMultiIndex
is (roughly)Meaning the constructor passes for
MultiIndex
with a single level, but essentially all methods fail or produce garbage:My original plan in #23167 was just to disable
MultiIndex.str
regardless of the number of levels, but @toobaz brought up the point (in a side discussion in #23670) that:This would, of course, work without problem. The main question that arises from this issue:
.str
-accessor be enabled forMultiIndex
at all?Index
or a 1-levelMultiIndex
?PS. As another link to #23670, one could maybe consider enabling
.str
for allMultiIndex
, by operating onMultiIndex.to_flat_index()
in those cases. This might be interesting for example for easy joining of theMultiIndex
-levels with.str.join
.The text was updated successfully, but these errors were encountered: