-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Incorrect index label displayed on MultiIndex DataFrame #14882
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
NB confirmed that this occurs in a build from the current master as well. |
Probably a pandas issue. I'm having trouble reproducing it with just from pandas import *
idx = MultiIndex(levels=[[30, 40, 50], [6, 12, 24], ['MRIgFUS', 'ablation', 'hysterectomy', 'iud', 'myomectomy', 'none', 'uae']],
labels=[[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2], [0, 1, 2, 3, 4, 5, 6, 0, 1, 2, 3, 4, 5, 6, 0, 1, 2, 3, 4, 5, 6, 0, 1, 2, 3, 4, 5, 6, 0, 1, 2, 3, 4, 5, 6, 0, 1, 2, 3, 4, 5, 6, 0, 1, 2, 3, 4, 5, 6, 0, 1, 2, 3, 4, 5, 6, 0, 1, 2, 3, 4, 5, 6]],
names=['age', 'followup', 'next intervention'])
df = pd.DataFrame({"A": 1}, index=idx)
df I suspect it's related to the particular sorting of your index (do you have repr issues with |
It's a pandas bug (pandas creates the html that jupyter displays), and has probably something to do with the truncation code. Because when you set the number of rows higher, eg |
I'm attempting to chase this down. @jorisvandenbossche is correct. It is the truncation code. |
I have a DataFrame with a hierarchical index as follows:
Notice in particular the values of the first two levels, and that they are balanced in the labels. However, the display of the table is incorrect. Here is what it looks like:
Notice the second label of the first two levels of the hierarchical index are repeated (40 and 40 instead of 40 and 50, and 12 and 12 instead of 12 and 24).
Output of
pd.show_versions()
pandas: 0.19.1
nose: None
pip: 9.0.1
setuptools: 31.0.1
Cython: 0.25.2
numpy: 1.11.2
scipy: 0.18.1
statsmodels: None
xarray: None
IPython: 5.1.0
sphinx: 1.5.1
patsy: 0.4.1
dateutil: 2.6.0
pytz: 2016.10
blosc: None
bottleneck: None
tables: None
numexpr: 2.6.1
matplotlib: 1.5.3
openpyxl: None
xlrd: 1.0.0
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: None
httplib2: None
apiclient: None
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: 2.8
boto: None
pandas_datareader: None
The text was updated successfully, but these errors were encountered: