-
- Notifications
You must be signed in to change notification settings - Fork 19.2k
Closed
Labels
API DesignIndexingRelated to indexing on series/frames, not to indexes themselvesRelated to indexing on series/frames, not to indexes themselvesInternalsRelated to non-user accessible pandas implementationRelated to non-user accessible pandas implementationRefactorInternal refactoring of codeInternal refactoring of code
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_tuplesandIndex.from_arraysare justMultiIndex.from_tuplesandMultiIndex.from_arraysmoved to classmethods ofIndex. -
droplevel, ` just raises on Index (right? what would it mean?): API: implement droplevels() for flat index #21115 -
has_duplicatesis straightforward -
truncateshould be equivalent to slicing -
reorder_levelsraises 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 -
levelsandlabelsproperty for Index - question on whether it should be sorted. - change to
renamebehavior:Indexwill accept either string or single-element list; MI continues to handle only list
Metadata
Metadata
Assignees
Labels
API DesignIndexingRelated to indexing on series/frames, not to indexes themselvesRelated to indexing on series/frames, not to indexes themselvesInternalsRelated to non-user accessible pandas implementationRelated to non-user accessible pandas implementationRefactorInternal refactoring of codeInternal refactoring of code