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

set_option('max_colwidth', N) not working on groupby output #7856

Closed
brifordwylie opened this issue Jul 27, 2014 · 5 comments
Closed

set_option('max_colwidth', N) not working on groupby output #7856

brifordwylie opened this issue Jul 27, 2014 · 5 comments
Labels
Bug Output-Formatting __repr__ of pandas objects, to_string
Milestone

Comments

@brifordwylie
Copy link

Hi All,

Might be pilot error (or the incorrect expectations), but I was expecting the max_colwidth option to work on groupby terminal output. Replication here:

$ python
> import pandas as pd
> df = pd.DataFrame([{'a':'foo','b':'bar','c':'uncomfortably long line with lots of stuff','d':1},  \
                                   {'a':'foo','b':'bar','c':'stuff', 'd':1}])
> df
     a    b                                           c  d
0  foo  bar  uncomfortably long line with lots of stuff  1
1  foo  bar                                       stuff  1

> pd.set_option('max_colwidth', 20)
> df
     a    b                    c  d
0  foo  bar  uncomfortably lo...  1
1  foo  bar                stuff  1

> group_df = df.groupby(['a','b','c']).sum()
> group_df
                                                    d
a   b   c                                            
foo bar stuff                                       1
        uncomfortably long line with lots of stuff  1
>>> 
>>> pd.show_versions()

INSTALLED VERSIONS
------------------
commit: None
python: 2.7.6.final.0
python-bits: 64
OS: Darwin
OS-release: 13.3.0
machine: x86_64
processor: i386
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8

pandas: 0.14.1
nose: None
Cython: 0.20.2
numpy: 1.8.1
scipy: None
statsmodels: None
IPython: 2.1.0
sphinx: 1.2.2
patsy: None
scikits.timeseries: None
dateutil: 2.2
pytz: 2014.4
bottleneck: None
tables: None
numexpr: None
matplotlib: None
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: None
httplib2: None
apiclient: None
rpy2: None
sqlalchemy: None
pymysql: None
psycopg2: None
>>> 
@jreback
Copy link
Contributor

jreback commented Jul 28, 2014

hmm, seems like a bug. that option is not well tested either, possibly related #7059

want to have a look; add some tests and see whats going on?

@jreback jreback added this to the 0.15.1 milestone Jul 28, 2014
@brifordwylie
Copy link
Author

Yeah, I'll poke around on this.. it will be a good learning experience for me. :)

@jorisvandenbossche
Copy link
Member

after discussion with @tiagoantao: the issue is that the max_colwidth is not applied to the index, only to the columns (so it has nothing really to do with groupby, but because of the groupby, the columns became a multi-index).

display.max_colwidth : int
    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.
    [default: 50] [currently: 50]

So literally, it is only applied to the columns, but I think it seems logical to also apply this maximum width to the index?

@tiagoantao
Copy link
Contributor

I have designed an embryo of solution for this. I would bet that this is naive, but maybe it suggests a way. It changes the way the index is rendered.
If you give me some directions, I can try to make this less naive:
https://github.com/tiagoantao/pandas/commit/55ed6f0953f2945046f47d1a796251b9bd599cdd

@jreback jreback modified the milestones: 0.16.0, Next Major Release, 0.16.1 Mar 6, 2015
jreback pushed a commit to jreback/pandas that referenced this issue Apr 28, 2015
jreback pushed a commit that referenced this issue Apr 28, 2015
@jreback
Copy link
Contributor

jreback commented Apr 28, 2015

closed by #8954

@jreback jreback closed this as completed Apr 28, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Output-Formatting __repr__ of pandas objects, to_string
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants