BUG: MultiIndex.repr is broken when display.max_seq_items = 1 · Issue #38415 · pandas-dev/pandas (original) (raw)


Note: Please read this guide detailing how to provide the necessary information for us to reproduce your bug.

Code Sample, a copy-pastable example

In[11]: pd.set_option("display.max_seq_items", 2) In[12]: pd.MultiIndex.from_tuples(tuples) Out[12]: MultiIndex([(1, 'red'), ... (2, 'blue')], length=40) In[13]: tuples = [(1, 'red'), (1, 'blue'), (2, 'red'), (2, 'blue')] In[14]: pd.MultiIndex.from_tuples(tuples) Out[14]: MultiIndex([(1, 'red'), ... (2, 'blue')], length=4) In[15]: pd.set_option("display.max_seq_items", 1) In[16]: pd.MultiIndex.from_tuples(tuples) Out[16]: MultiIndex([... (1, 'red'), (1, 'blue'), (2, 'red'), (2, 'blue')], length=4)

Problem description

The output of MultiIndex.__repr__ is dependent on display.max_seq_items, the output is correct for different values of max_seq_items except when it is set to 1. When it is set to 1, the entire records in MultiIndex are being printed and also "..." are being prepended to the data output.

Expected Output

In[12]: pd.MultiIndex.from_tuples(tuples) Out[12]: MultiIndex([(1, 'red'), ...], length=40)

Output of pd.show_versions()

INSTALLED VERSIONS

commit : b5958ee
python : 3.7.9.final.0
python-bits : 64
OS : Linux
OS-release : 5.4.0-53-generic
Version : #59-Ubuntu SMP Wed Oct 21 09:38:44 UTC 2020
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8
pandas : 1.1.5
numpy : 1.19.4
pytz : 2020.4
dateutil : 2.8.1
pip : 20.3.1
setuptools : 49.6.0.post20201009
Cython : 0.29.21
pytest : 6.1.2
hypothesis : 5.43.3
sphinx : 3.3.1
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 2.11.2
IPython : 7.19.0
pandas_datareader: None
bs4 : None
bottleneck : None
fsspec : 0.8.4
fastparquet : None
gcsfs : None
matplotlib : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : 1.0.1
pytables : None
pyxlsb : None
s3fs : None
scipy : None
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
numba : 0.52.0