Skip to content

Missing ellipsis cells in pivot_table.to_html when limited by max_cols and len(rows) > 1 #6131

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
BertrandBordage opened this issue Jan 27, 2014 · 8 comments · Fixed by #22588
Labels
good first issue IO HTML read_html, to_html, Styler.apply, Styler.applymap Output-Formatting __repr__ of pandas objects, to_string Testing pandas testing functions or related to the test suite
Milestone

Comments

@BertrandBordage
Copy link

import pandas
df = pandas.DataFrame([
    {'a': 'aa', 'b': 'ba', 'c': 'ca', 'd': 1},
    {'a': 'ab', 'b': 'bb', 'c': 'cc', 'd': 2},
    {'a': 'ac', 'b': 'bc', 'c': 'cc', 'd': 3}
])

df.pivot_table(cols=['a'], rows=['b', 'c']).to_html(max_cols=2)

This renders like this:
broken_output

while this:

df.pivot_table(cols=['a'], rows=['b']).to_html(max_cols=2)

renders like this:
slection_656

As you can see in the first table, there are no ellipsis cells like in the second one.
I inspected the code to find the reason for this bug but couldn't find…

@jreback jreback modified the milestones: 0.15.0, 0.14.0 Apr 9, 2014
@jreback jreback modified the milestones: 0.16.0, Next Major Release Mar 3, 2015
@mroeschke
Copy link
Member

This looks fixed; output formatting for dataframes has changed since this version though. A test would be good to confirm

@mroeschke mroeschke added Testing pandas testing functions or related to the test suite good first issue labels Jul 6, 2018
@simonjayhawkins
Copy link
Member

using pandas 0.23.0 i appear to get the desired behaviour

image

however, i came to the issue from #15019, so decided to add index=False to the output

image

@mroeschke
Copy link
Member

If you're up for contributing a test @simonjayhawkins to confirm this behavior, it would be much appreciated!

@simonjayhawkins
Copy link
Member

the column misalignment in Out[4] and Out[5] above is a separate issue. This was fixed for a column MultiIndex in #8452. adding an index MultiIndex to the same example appears to still gives the column offset bug.

image

so this should probably be raised as a new issue?

@mroeschke
Copy link
Member

Sure thing; you can open a new issue. Please use code snippets and not pictures of code as it's harder to reproduce.

@simonjayhawkins
Copy link
Member

Opened #22579 for the column misalignment.

@simonjayhawkins
Copy link
Member

simonjayhawkins commented Sep 4, 2018

@mroeschke currently in pandas\tests\io\formats\test_to_html.py there is a test:

    def test_to_html_truncate_multi_index(self):
        pytest.skip("unreliable on travis")
        arrays = [['bar', 'bar', 'baz', 'baz', 'foo', 'foo', 'qux', 'qux'],
                  ['one', 'two', 'one', 'two', 'one', 'two', 'one', 'two']]
        df = DataFrame(index=arrays, columns=arrays)
        fmt.set_option('display.max_rows', 7)
        fmt.set_option('display.max_columns', 7)
        result = df._repr_html_()
        expected = '''\
...

which tests that:

image

produces:

image

which I think covers this issue. so i'm thinking that adding another test may not be necessary?

@mroeschke
Copy link
Member

Although these tests look similar, it would still be good to confirm that the to_html pathway is tested. The test uses a private method _repr_html_ which users should not normally be accessing.

@jreback jreback modified the milestones: Contributions Welcome, 0.24.0 Sep 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue IO HTML read_html, to_html, Styler.apply, Styler.applymap Output-Formatting __repr__ of pandas objects, to_string Testing pandas testing functions or related to the test suite
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants