Closed

Description
Have you ever written code that looks like this:
if isinstance(d.index, MultiIndex):
results = []
for l in d.index.levels:
for x in baz(l):
results.append(foo)
elif isinstance(d.index, Index):
for x in d.index:
foo
I've had to special case the handling of index vs. multindex several times in the past.
Conceptually, I should be able to treat index as a private case of MultIndex
with nlevels =1, and supporting that in the API would make things nicer.
Edit by @cpcloud:
Tasks :
API Unification
Method unification is relatively simple:
-
Index.from_tuples
andIndex.from_arrays
are justMultiIndex.from_tuples
andMultiIndex.from_arrays
moved to classmethods ofIndex
. -
droplevel
, ` just raises on Index (right? what would it mean?): API: implement droplevels() for flat index #21115 -
has_duplicates
is straightforward -
truncate
should be equivalent to slicing -
reorder_levels
raises if not level=0 or name of index -
equal_levels
- straightforward -
levshape
- (len(ind),) -
sortorder
- None -
get_loc_level
- I think meaningless with tuple, raises whatever if not 0 or index name -
is_lexsorted
- doesn't need to change -
is_lexosrted_tuple
- doesn't need to change -
is_monotonic_*
-
lexsort_depth
- doesn't need to be changed at all -
searchsorted
-
repeat
-
levels
andlabels
property for Index - question on whether it should be sorted. - change to
rename
behavior:Index
will accept either string or single-element list; MI continues to handle only list