BUG: inconsistent naming when combining indices of various types #35847
Labels
API - Consistency
Internal Consistency of API/Behavior
Needs Discussion
Requires discussion from core team before further action
Milestone
This is building off of some issues seen in #13475 and subsequent PR. Essentially, the resulting index name when combining existing named indices with
union_indexes
is not consistent across index types. This primarily affectsconcat
and theDataFrame
constructor, which callunion_indexes
.When combining named indices, there are three main name resolution rules I can think of:
ignore
: assign no name to outputunanimous
: assign name if all names agreeconsensus
: assign name only if one unique non-null nameWith some testing, below is my best understanding of what resolution rule the various index types use. Note that the behavior may differ depending on whether the indices are numerically equal or not, as with RangeIndex. For the not numerically equal case:
Index
: consensusRangeIndex
: ignoreInt64Index
: unanimousFloat64Index
: unanimousDateTimeIndex
: consensusTimeDeltaIndex
: consensusPeriodIndex
: unanimousCategoricalIndex
: unanimousMultiIndex
: unanimous (over all levels)I'm not really taking a stand on the correct name resolution rule, but I think they should at least be consistent across index type! And of course MultiIndex is a bit more complicated. Seems possible things could be implemented in common for non-multi-indices in the higher level
union
function? I'm not really sure, but I'm happy to put some work into it.The test is slightly different for each index type, but for the RangeIndex case, here's an MWE:
and the result will have no name (checked on master).
The text was updated successfully, but these errors were encountered: