COMPAT: HTML styling for MI and notebook 5.0 by TomAugspurger · Pull Request #16080 · pandas-dev/pandas (original) (raw)

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 andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation11 Commits1 Checks0 Files changed

Conversation

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters

[ Show hidden characters]({{ revealButtonHref }})

TomAugspurger

Fixes the visual styling of MI labels in notebook 5.0

Small summary:

Closes #15379

@TomAugspurger

Fixes the visual styling of MI labels in notebook 5.0

@TomAugspurger

Master:

screen shot 2017-04-20 at 9 41 53 pm

PR:

screen shot 2017-04-20 at 9 41 59 pm

Anything I missed? I'm not sure the best way to handle the odd shading on some MultiIndexes yet...

@codecov

@jorisvandenbossche

@TomAugspurger thanks!

My main concern is that it may look a bit strange in certain cases if the header is left aligned and the values right-aligned (the example you show has consistent width columns, but that is not always the case)

@jorisvandenbossche

Small example:

screenshot from 2017-04-21 09-48-43

But probably not much to do about that, unless we left-align the full columns as well

@TomAugspurger

My main concern is that it may look a bit strange in certain cases if the header is left aligned

Yeah, that's unfortunate. I think that's worth the tradeoff for now though. I wasn't able to easily get any nice-looking vertical borders on just the columns of the MI that needed it. And I don't want to put in too much work, as ideally this code will be getting ripped out at some point (there's some IPython 2.x compatibility code in there 😆 ), but don't have time for that now.

@jorisvandenbossche

Yes, this is certainly already much better!
The other (easy) option is just to also left-align all values (as it was before I think?), but not sure if that is worth it.

@TomAugspurger

The other (easy) option is just to also left-align all values (as it was before I think?), but not sure if that is worth it.

Are you thinking to left-align always, or left-align only if there's a MI in the columns?

I think there's no way to control the table body alignment based on the number of rows in the MultiIndex. I was only able to retain the default right-alignment for non-MI by using the only-child pseudo-selector. But this could only affect the column headers.

I think I prefer the right-alignment in general, so it'd be a pity to lose that.

@jorisvandenbossche

I think there's no way to control the table body alignment based on the number of rows in the MultiIndex.

Ah, yes, I was thinking: but we control the generation, so we can just change the style tag based on whether we are displaying a multi-index header or not. But of course, css doesn't work that way as it would change all tables in the notebook (unless we start adding unique identifiers as in .style)

I think I prefer the right-alignment in general, so it'd be a pity to lose that.

OK, then let's leave it as is? we can always further refine later on if there comes feedback!

pcluo pushed a commit to pcluo/pandas that referenced this pull request

May 22, 2017

@TomAugspurger @pcluo

Fixes the visual styling of MI labels in notebook 5.0

@margotphoenix

I think the code that was added here didn't just affect multiindex tables, but all tables. As a result, tables with long string values look awkward, with the row indices vertically top-aligned and values vertically middle-aligned.

screen shot 2017-06-27 at 9 47 48 pm

I have tried to fix this using custom css, but the css produced from this code overrides anything I try.

@TomAugspurger

@maxwasserman can you post what version version of the notebook you're using, and show before / after screenshots? Perhaps open a new issue so we can track it there.

@margotphoenix

I had just upgraded from pandas 0.19.2 to 0.20.2 over the weekend, then upgraded from notebook 4.1.0 to 5.0.0 yesterday. Python version is 2.7.13.

With pandas 0.19.2 and notebook 4.1.0 (Before Upgrading):
screen shot 2017-06-28 at 10 46 37 am

With pandas 0.20.2 and notebook 4.1.0 (After Upgrading Pandas):
screen shot 2017-06-28 at 1 08 54 pm

With pandas 0.20.2 and notebook 5.0.0 (After Upgrading Both):
screen shot 2017-06-28 at 1 13 19 pm

The change in alignment for row indices and column names happened when I upgraded pandas.