-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Index(data=..., dtype=CategoricalDtype(...)) doesn't maintain dtype #19032
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
thought we had an issue for this one, ok, IIRC cc @jschendel @jorisvandenbossche @TomAugspurger |
My previous PR's related to CDT were in the context of pandas/pandas/core/indexes/base.py Lines 198 to 200 in 04beec7
Will open a PR to fix it later today. |
Could you maybe also do the same for This should only be 2 lines more.... |
FWIW, I'm thinking through this type of issue with #18767 I'd recommend avoiding more
blocks for now. |
The block is actually already there, so it's really just a matter of passing Planning to open an issue in the near future to allow subtype conversion for |
👍 then. |
Great, thanks. FYI, my use case is combining several series of the same dtype, and there may be several such groups. If I can pre-register the dtype, I can covert to the result index simply by |
Code Sample, a copy-pastable example if possible
Problem description
Notice that the index isn't ordered and the categories have changed location.
If construction goes through CategoricalIndex, everything is ok.
Expected Output
Expected output is
CategoricalIndex(['German', 'English', 'French'], categories=['German', 'English', 'French'], ordered=True)
.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.1
pytest: 3.2.1
pip: 9.0.1
setuptools: 36.5.0.post20170922
Cython: 0.26.1
numpy: 1.11.3
scipy: 1.0.0
pyarrow: None
xarray: None
IPython: 6.1.0
sphinx: 1.6.5
patsy: None
dateutil: 2.6.1
pytz: 2017.2
blosc: None
bottleneck: None
tables: None
numexpr: None
feather: None
matplotlib: 2.1.0
openpyxl: 2.4.8
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: 1.0.1
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: 2.9.6
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None
The text was updated successfully, but these errors were encountered: