Description
Code Sample, a copy-pastable example if possible
>>> c = pd.api.types.CategoricalDtype('c b a'.split(), ordered=True)
>>> c
CategoricalDtype(categories=['c', 'b', 'a'], ordered=True)
>>> pd.CategoricalIndex('a b b c'.split(), dtype=c)
CategoricalIndex(['a', 'b', 'b', 'c'], categories=['a', 'b', 'c'], ordered=False, dtype='category')
Note that categories
and ordered
above do not follow the rules from c
.
Problem description
Using pd.Categorical(..., dtype=c)
works in v0.21, so IMO pd.CategoricalIndex(..., dtype=c)
should work as well, but deosn't.
Expected Output
>>> pd.CategoricalIndex('a b b c'.split(), dtype=c)
CategoricalIndex(['a', 'b', 'b', 'c'], categories=['c', 'b', 'a'], ordered=True, dtype='category')
Note that categories
and ordered
do follow the rules from c
in this expected version.
Output of pd.show_versions()
INSTALLED VERSIONS
commit: None
python: 3.6.3.final.0
python-bits: 32
OS: Windows
OS-release: 10
machine: AMD64
processor: Intel64 Family 6 Model 78 Stepping 3, GenuineIntel
byteorder: little
LC_ALL: None
LANG: None
LOCALE: None.None
pandas: 0.21.0
pytest: 3.2.1
pip: 9.0.1
setuptools: 36.5.0.post20170922
Cython: None
numpy: 1.11.3
scipy: None
pyarrow: None
xarray: None
IPython: 6.1.0
sphinx: None
patsy: None
dateutil: 2.6.1
pytz: 2017.2
blosc: None
bottleneck: None
tables: None
numexpr: None
feather: None
matplotlib: None
openpyxl: 2.4.8
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: None
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: 2.9.6
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None