Skip to content
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

Formatting of CategoricalIndex misaligned if NaNs are present #25061

Closed
JustinZhengBC opened this issue Jan 31, 2019 · 0 comments

Comments

@JustinZhengBC
Copy link
Contributor

commented Jan 31, 2019

Code Sample, a copy-pastable example if possible

>>> import pandas as pd
>>> pd.DataFrame([[1],[2]], index=pd.CategoricalIndex([1, pd.np.nan]))
      0
 1.0  1
NaN   2

Problem description

CategoricalIndex of a DataFrame is misaligned when printing if it contains NaN values.

Expected Output

>>> import pandas as pd
>>> pd.DataFrame([[1],[2]], index=pd.CategoricalIndex([1, pd.np.nan]))
      0
1.0   1
NaN   2

Output of pd.show_versions()

No module named 'dask'

INSTALLED VERSIONS

commit: da5f5eb
python: 3.6.6.final.0
python-bits: 64
OS: Darwin
OS-release: 18.0.0
machine: x86_64
processor: i386
byteorder: little
LC_ALL: None
LANG: en_CA.UTF-8
LOCALE: en_CA.UTF-8

pandas: 0.24.0.dev0+1684.gda5f5eb6c
pytest: 4.0.0
pip: 10.0.1
setuptools: 40.6.2
Cython: 0.29
numpy: 1.14.2
scipy: 1.1.0
pyarrow: 0.11.1
xarray: 0.11.0
IPython: 7.1.1
sphinx: 1.8.2
patsy: 0.5.0
dateutil: 2.7.5
pytz: 2018.7
blosc: None
bottleneck: 1.2.1
tables: 3.4.4
numexpr: 2.6.8
feather: None
matplotlib: 3.0.1
openpyxl: 2.5.9
xlrd: 1.1.0
xlwt: 1.2.0
xlsxwriter: 1.1.2
lxml.etree: 4.2.5
bs4: 4.6.3
html5lib: 1.0.1
sqlalchemy: 1.2.14
pymysql: 0.9.2
psycopg2: None
jinja2: 2.10
s3fs: 0.1.6
fastparquet: 0.2.1
pandas_gbq: None
pandas_datareader: None
gcsfs: 0.1.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.