Skip to content
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

df.to_html display full output when using option to set display.max_colwidth #28218

Closed
Leostayner opened this issue Aug 29, 2019 · 4 comments
Closed
Labels
Closing Candidate May be closeable, needs more eyeballs Docs IO HTML read_html, to_html, Styler.apply, Styler.applymap

Comments

@Leostayner
Copy link

Code Sample

import pandas as pd

df = pd.DataFrame(data={
    'test': ['abcdefghijklmnopqrstuvwxyz', 'aaaabbbbbbccccccddddddeeeeefffff'],
})

pd.set_option('display.max_colwidth', 10)
df.to_html(escape=False, notebook=False)

Problem description

While we are working on issue #9690 and trying to reproduce the bug we found what could be a possible bug, when using pd.set_option('display.max_colwidth', 10), we expect df.to_html(escape=False, notebook=False) to show truncated values, but this does not occurs.

We already know that when using notebook=True the truncating occurs, but in our mind that to should working too when notebook=False. Should this be this way?

Output

'<table border="1" class="dataframe">\n  <thead>\n    <tr style="text-align: right;">\n      <th></th>\n      <th>test</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>abcdefghijklmnopqrstuvwxyz</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>aaaabbbbbbccccccddddddeeeeefffff</td>\n    </tr>\n  </tbody>\n</table>'

Expected Output

'<table border="1" class="dataframe">\n  <thead>\n    <tr style="text-align: right;">\n      <th></th>\n      <th>test</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>abcdef...</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>aaaabb...
</td>\n    </tr>\n  </tbody>\n</table>'

Output of pd.show_versions()

INSTALLED VERSIONS

commit : 5f34933
python : 3.6.8.final.0
python-bits : 64
OS : Linux
OS-release : 4.15.0-58-generic
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : pt_BR.UTF-8
LOCALE : pt_BR.UTF-8

pandas : 0.25.0+258.g5f3493384
numpy : 1.16.2
pytz : 2018.3
dateutil : 2.8.0
pip : 9.0.1
setuptools : 40.8.0
Cython : 0.29.13
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : 4.2.1
html5lib : 0.999999999
pymysql : None
psycopg2 : None
jinja2 : 2.10.1
IPython : 7.3.0
pandas_datareader: None
bs4 : 4.6.0
bottleneck : None
fastparquet : None
gcsfs : None
lxml.etree : 4.2.1
matplotlib : 3.0.2
numexpr : 2.6.4
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pytables : None
s3fs : None
scipy : 1.2.1
sqlalchemy : None
tables : 3.4.2
xarray : None
xlrd : None
xlwt : None
xlsxwriter : None

@elisamalzoni
@simonjayhawkins simonjayhawkins added the IO HTML read_html, to_html, Styler.apply, Styler.applymap label Aug 29, 2019
@simonjayhawkins
Copy link
Member

I'm not sure I follow. notebook=False is the default for to_html (i.e. the generated HTML is NOT for IPython Notebook.)

In this case, the output should NOT be truncated (i.e. ignore pd.set_option('display.max_colwidth', 10)), irrespective of the value of escape?

@Leostayner
Copy link
Author

So notebook=False should not truncate? We're a little confused with that, we couldn't find this specification in the documentation. Is there anywhere describing this? If so, where?

https://pandas.pydata.org/pandas-docs/stable/user_guide/options.html#available-options

The maximum width in characters of a column in the repr of a pandas data structure. When the column overflows, a “…” placeholder is embedded in the output.

@lshepard
Copy link

lshepard commented Sep 7, 2019

The change to not truncate to_html was made intentionally a few years ago: #17004

@mroeschke mroeschke added the Docs label May 7, 2020
@attack68 attack68 added the Closing Candidate May be closeable, needs more eyeballs label Sep 9, 2021
@mroeschke
Copy link
Member

Appears this is the expected behavior when implemented in #24841 so closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Closing Candidate May be closeable, needs more eyeballs Docs IO HTML read_html, to_html, Styler.apply, Styler.applymap
Projects
None yet
Development

No branches or pull requests

5 participants