Skip to content

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

Closed
@Leostayner

Description

@Leostayner

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Closing CandidateMay be closeable, needs more eyeballsDocsIO HTMLread_html, to_html, Styler.apply, Styler.applymap

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions