Skip to content

Pandas should validate display.max_rows option #23348

Closed
@cosinequanon

Description

@cosinequanon

Code Sample, a copy-pastable example if possible

import pandas as pd
pd.set_option('display.max_rows', -1)
test = [['a', 'b'] ,['c','d'] ,['f','g']]
pd.DataFrame(test, columns=['columna', 'columnb'])

Problem description

This incorrectly print's 4 rows:

Out[1]:
..     ...     ...
   columna columnb
0        a       b
1        c       d
1        c       d
2        f       g

[3 rows x 2 columns]

Pandas should not allow negative numbers for this setting because it does non-sensical things. In many other places -1 is used to represent an unbounded number so setting it -1 is actually intuitive but it doesn't work correctly and we should fail fast instead of confusing users.

Expected Output

Out[1]:
..     ...     ...
   columna columnb
0        a       b
1        c       d
2        f       g

[3 rows x 2 columns]

Output of pd.show_versions()

[paste the output of pd.show_versions() here below this line]
INSTALLED VERSIONS

commit: None
python: 3.6.3.candidate.1
python-bits: 64
OS: Linux
OS-release: 4.11.3-67_fbk17_4093_g2bf19e7a0b95
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL:
LANG: en_US.UTF-8
LOCALE: en_US.UTF-8

pandas: 0.23.4
pytest: None
pip: None
setuptools: 40.4.3
Cython: 0.29a0
numpy: 1.15.1
scipy: 1.1.0
pyarrow: None
xarray: None
IPython: 6.5.0
sphinx: None
patsy: 0.4.1
dateutil: 2.7.3
pytz: 2018.4
blosc: None
bottleneck: None
tables: None
numexpr: None
feather: None
matplotlib: 2.2.3
openpyxl: 2.4.11
xlrd: 0.9.4
xlwt: None
xlsxwriter: None
lxml: 3.5.0
bs4: None
html5lib: 0.9999999
sqlalchemy: 1.1.13
pymysql: None
psycopg2: None
jinja2: 2.10
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None

Metadata

Metadata

Assignees

No one assigned

    Labels

    Error ReportingIncorrect or improved errors from pandasOutput-Formatting__repr__ of pandas objects, to_string

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions