-
-
Couldn't load subscription status.
- Fork 19.2k
Closed
Labels
BugCategoricalCategorical Data TypeCategorical Data TypeIndexingRelated to indexing on series/frames, not to indexes themselvesRelated to indexing on series/frames, not to indexes themselves
Milestone
Description
.loc against CategoricalIndex with values included in its categories but not appears as codes results in normal Index
import numpy as np
import pandas as pd
index = pd.CategoricalIndex(list('aabbca'), categories=list('cabe'))
df = pd.DataFrame({'A' : np.arange(6,dtype='int64')}, index=index)
# OK
df.loc[['a', 'b']].index
# CategoricalIndex([u'a', u'a', u'a', u'b', u'b'], categories=[u'c', u'a', u'b', u'e'], ordered=False, dtype='category')
# NG, must be CategoricalIndex
df.loc[['a', 'b', 'e']].index
# Index([u'a', u'a', u'a', u'b', u'b', u'e'], dtype='object')
Even though this is tested here, it doesn't check dtype.
Metadata
Metadata
Assignees
Labels
BugCategoricalCategorical Data TypeCategorical Data TypeIndexingRelated to indexing on series/frames, not to indexes themselvesRelated to indexing on series/frames, not to indexes themselves