Skip to content

no warning with invalid pd.set_option('display.max_colwidth') #16097

@jkornblum

Description

@jkornblum

Code Sample, a copy-pastable example if possible

import pandas as pd

df = pd.DataFrame(np.array([['foo', 'bar', 'bim', 'uncomfortably long string'], ['horse', 'cow', 'banana', 'apple']]))
df
#       0    1       2                          3
# 0    foo  bar     bim  uncomfortably long string
# 1  horse  cow  banana                      apple

pd.set_option('max_colwidth', 2)
df
#       0    1       2                          3
# 0    foo  bar     bim  uncomfortably long string
# 1  horse  cow  banana                      apple

pd.set_option('max_colwidth', 6)
df
#       0    1      2      3
# 0    foo  bar    bim  un...
# 1  horse  cow  ba...  apple

Problem description

When I set the max_colwidth option to 3 or fewer it does not function and gives no warning.
I assume that the ellipses take three characters so it has little meaning if you set the option less than 3.
I think it should warn the user about the invalid setting or display an ellipse filled DataFrame.

Maybe the documentation could be updated to show range of 3 to xx.

Expected Output

pd.set_option('max_colwidth', 2)
# raise ValueError (or similar) .... 
# Invalid argument 2 specificied the minimum is 4

## OR just respond to the new setting but display a useless DateFrame

df
#       0   1   2   3
# 0    ..  ..  ..  ..
# 1    ..  ..  ..  ..

Output of pd.show_versions()

INSTALLED VERSIONS ------------------ commit: None python: 3.6.0.final.0 python-bits: 64 OS: Windows OS-release: 10 machine: AMD64 processor: Intel64 Family 6 Model 42 Stepping 7, GenuineIntel byteorder: little LC_ALL: None LANG: None LOCALE: None.None

pandas: 0.19.2
nose: 1.3.7
pip: 9.0.1
setuptools: 27.2.0
Cython: 0.25.2
numpy: 1.11.3
scipy: 0.18.1
statsmodels: 0.6.1
xarray: None
IPython: 5.1.0
sphinx: 1.5.1
patsy: 0.4.1
dateutil: 2.6.0
pytz: 2016.10
blosc: None
bottleneck: 1.2.0
tables: 3.2.2
numexpr: 2.6.1
matplotlib: 2.0.0
openpyxl: 2.4.1
xlrd: 1.0.0
xlwt: 1.2.0
xlsxwriter: 0.9.6
lxml: 3.7.2
bs4: 4.5.3
html5lib: None
httplib2: None
apiclient: None
sqlalchemy: 1.1.5
pymysql: None
psycopg2: None
jinja2: 2.9.4
boto: 2.45.0
pandas_datareader: None

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions