Skip to content

BUG: display.max_seq_items set to 0 is treated as None #48092

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

Closed
3 tasks done
MarcoGorelli opened this issue Aug 15, 2022 · 4 comments
Closed
3 tasks done

BUG: display.max_seq_items set to 0 is treated as None #48092

MarcoGorelli opened this issue Aug 15, 2022 · 4 comments
Labels
Output-Formatting __repr__ of pandas objects, to_string

Comments

@MarcoGorelli
Copy link
Member

Pandas version checks

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pandas.

  • I have confirmed this bug exists on the main branch of pandas.

Reproducible Example

import pandas as pd

df = pd.DataFrame({'a': [1,2,3]})

with pd.option_context('display.max_rows', 1):
    print(df)
with pd.option_context('display.max_rows', 0):
    print(df)

Issue Description

1 only prints one row, but 0 prints all of them:

    a
0   1
.. ..

[3 rows x 1 columns]
   a
0  1
1  2
2  3

Expected Behavior

    a
0   1
.. ..

[3 rows x 1 columns]
    a
.. ..

[3 rows x 1 columns]

Installed Versions

/home/marco/miniconda3/envs/pandas-dev/lib/python3.8/site-packages/_distutils_hack/init.py:33: UserWarning: Setuptools is replacing distutils.
warnings.warn("Setuptools is replacing distutils.")

INSTALLED VERSIONS

commit : 06dd5da
python : 3.8.13.final.0
python-bits : 64
OS : Linux
OS-release : 5.4.0-121-generic
Version : #137-Ubuntu SMP Wed Jun 15 13:33:07 UTC 2022
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_GB.UTF-8
LOCALE : en_GB.UTF-8

pandas : 1.5.0.dev0+1295.g06dd5dab93
numpy : 1.22.4
pytz : 2022.2
dateutil : 2.8.2
setuptools : 63.2.0
pip : 22.2.2
Cython : 0.29.32
pytest : 7.1.2
hypothesis : 6.47.1
sphinx : 4.5.0
blosc : None
feather : None
xlsxwriter : 3.0.3
lxml.etree : 4.9.1
html5lib : 1.1
pymysql : 1.0.2
psycopg2 : 2.9.3
jinja2 : 3.0.3
IPython : 8.4.0
pandas_datareader: 0.10.0
bs4 : 4.11.1
bottleneck : 1.3.5
brotli :
fastparquet : 0.8.1
fsspec : 2021.07.0
gcsfs : 2021.07.0
matplotlib : 3.3.2
numba : 0.55.2
numexpr : 2.8.0
odfpy : None
openpyxl : 3.0.9
pandas_gbq : 0.15.0
pyarrow : 2.0.0
pyreadstat : 1.1.9
pyxlsb : 1.0.9
s3fs : 2021.07.0
scipy : 1.9.0
snappy :
sqlalchemy : 1.4.40
tables : 3.7.0
tabulate : 0.8.10
xarray : 2022.6.0
xlrd : 2.0.1
xlwt : 1.3.0
zstandard : 0.18.0
tzdata : None
None

@MarcoGorelli MarcoGorelli added Bug Needs Triage Issue that has not been reviewed by a pandas team member Output-Formatting __repr__ of pandas objects, to_string good first issue and removed Bug Needs Triage Issue that has not been reviewed by a pandas team member good first issue labels Aug 15, 2022
@MarcoGorelli
Copy link
Member Author

Likewise for max_seq_items

@dizhouwu
Copy link

can replicate. just curious why there is a use case where you need to display 0 rows?

@MarcoGorelli
Copy link
Member Author

It came out of #48033 when the user wanted to hide the current output

@MarcoGorelli
Copy link
Member Author

MarcoGorelli commented Aug 15, 2022

Though they also wanted to add extra text to the output which pandas currently doesn't print

Probably not worth adding complexity for this, = max_seq_items or get_option("max_seq_items") or len(seq) is nice and simple

closing then, but can reopen if someone does come along with a use-case

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Output-Formatting __repr__ of pandas objects, to_string
Projects
None yet
Development

No branches or pull requests

2 participants