Skip to content

multi-index display bug #12223

Closed
Closed
@s-wakaba

Description

@s-wakaba

Thanks for great tool!

When printing a long DataFrame with multi-index which are result of set_index(..., append=True),
displaying index values look strange.

import pandas as pd

def func(n):
    x = [
        [['a1-%d' % i, 'a2-%d' % i] for i in range(n)],
        [['b1-%d' % i, 'b2-%d' % i] for i in range(n)],
    ]
    y = pd.concat([pd.DataFrame(a) for a in x], keys=['X', 'Y']).set_index(1, append=True)
    print(y)

func(5) # no problem
func(50) # bug!

When DataFrames are short (in this case, 10 rows), there is no problem.
However, when DataFrames is long (in this case, 100 rows) and omitted middle-part on printing, some columns of index is not correct.

             0
    1         
X 0 a2-0  a1-0
  1 a2-1  a1-1
  2 a2-2  a1-2
  3 a2-3  a1-3
  4 a2-4  a1-4
Y 0 b2-0  b1-0
  1 b2-1  b1-1
  2 b2-2  b1-2
  3 b2-3  b1-3
  4 b2-4  b1-4
                   0
        1           
X a2-0  a2-0    a1-0
  a2-1  a2-1    a1-1
  a2-2  a2-2    a1-2
  a2-3  a2-3    a1-3
  a2-4  a2-4    a1-4
  a2-5  a2-5    a1-5
  a2-6  a2-6    a1-6
  a2-7  a2-7    a1-7
  a2-8  a2-8    a1-8
  a2-9  a2-9    a1-9
...              ...
Y b2-40 b2-40  b1-40
  b2-41 b2-41  b1-41
  b2-42 b2-42  b1-42
  b2-43 b2-43  b1-43
  b2-44 b2-44  b1-44
  b2-45 b2-45  b1-45
  b2-46 b2-46  b1-46
  b2-47 b2-47  b1-47
  b2-48 b2-48  b1-48
  b2-49 b2-49  b1-49

[100 rows x 1 columns]

result of pd.show_versions() is as follows.

INSTALLED VERSIONS
------------------
commit: None
python: 3.5.1.final.0
python-bits: 64
OS: Linux
OS-release: 2.6.32-279.22.1.el6.x86_64
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8

pandas: 0.17.1
nose: 1.3.7
pip: 7.1.2
setuptools: 18.5
Cython: 0.23.4
numpy: 1.10.1
scipy: 0.16.0
statsmodels: 0.6.1
IPython: 4.0.1
sphinx: 1.3.1
patsy: 0.4.0
dateutil: 2.4.2
pytz: 2015.7
blosc: None
bottleneck: 1.0.0
tables: 3.2.2
numexpr: 2.4.4
matplotlib: 1.5.0
openpyxl: 2.2.6
xlrd: 0.9.4
xlwt: 1.0.0
xlsxwriter: 0.7.7
lxml: 3.4.4
bs4: 4.4.1
html5lib: None
httplib2: None
apiclient: None
sqlalchemy: 1.0.9
pymysql: None
psycopg2: None
Jinja2: None

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions