-
-
Notifications
You must be signed in to change notification settings - Fork 18.7k
Closed
Labels
CategoricalCategorical Data TypeCategorical Data TypeEnhancementIndexingRelated to indexing on series/frames, not to indexes themselvesRelated to indexing on series/frames, not to indexes themselves
Description
When #7217 becomes available, it would be nice to also have a 'CategoricalIndex' so that the sorting behaviour based on levels will be preserved when a categorical becomes a index:
cats = pd.Categorical([1,2,3,4], levels=[4,2,3,1])
strings = ["a","b","c","d"]
values = [4,2,3,1]
df = pd.DataFrame({"strings":strings, "values":values}, index=cats)
df.index
# This should sort by levels but does not as there is no CategoricalIndex!
df.sort_index()
CC: @shoyer
Metadata
Metadata
Assignees
Labels
CategoricalCategorical Data TypeCategorical Data TypeEnhancementIndexingRelated to indexing on series/frames, not to indexes themselvesRelated to indexing on series/frames, not to indexes themselves