-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Show Index Headers on DataFrames with Style #12090
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
Conversation
@@ -206,6 +206,22 @@ def _translate(self): | |||
"class": " ".join(cs)}) | |||
head.append(row_es) | |||
|
|||
if self.data.index.names: | |||
index_header = [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
possibly rename to index_row
for clarity.
tests pls |
@jreback tests added. Do you think I need to add more tests? |
Just gave a quick look, and the changes look good to me. Could you add a release note in Slightly off topic, but I saw your PrettyPandas the other day, looks great! Feel free to bug me with anything that's causing you difficulty with developing that. I've been busy with other types of work, so I haven't had time to actually use |
@@ -130,6 +130,38 @@ def test_set_properties_subset(self): | |||
expected = {(0, 0): ['color: white']} | |||
self.assertEqual(result, expected) | |||
|
|||
def test_index_name(self): | |||
df = pd.DataFrame({'A': [1, 2], 'B': [3, 4], 'C': [5, 6]}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add the issue number as a comment here (and below)
@HHammond some small comments. otherwise looks good. |
can you run |
d54cb4c
to
47cfe4f
Compare
@TomAugspurger Thanks, I'm glad you like PrettyPandas. I'll try and explore the limits of what It's been added to the what's new page, I've added the issue to the tests, and flake8 is happy with my patch. Anything else you guys need? |
@jreback is this good to merge? |
@TomAugspurger ball in your court |
Squashed |
Show Index Headers on DataFrames with Style
@HHammond thanks! |
Please use the patch tool next time! |
Sorry, I remembered that seconds after merging, old habits :) |
No problem, but there's no need to ask people to squash any more either if you use that tool (unless there is some messy commit history or merge commits, of course). |
Still mismatches with normal @HHammond Appreciated if you can work. |
I can take a look at that on Sunday or Monday. |
@TomAugspurger I have a patch for @sinhrks request, is it something that belongs in #12162 or would you prefer I create a new PR for that? Patch:
|
You can do it as a separate PR if you have a chance. You might want to base it off #12162 to avoid merge conflicts. |
PR: #12260 |
Addresses #12090 (comment) by making the `Styler` behaviour match regular `to_html` behaviour. This PR is based from #12162. ##### New behaviour <img width="596" alt="screen shot 2016-02-08 at 10 35 23 am" src="https://cloud.githubusercontent.com/assets/3064019/12890011 /b183e81e-ce4f-11e5-9b9f-c021fcb33c5a.png"> cc @TomAugspurger Author: Tom Augspurger <[email protected]> Author: Henry Hammond <[email protected]> Closes #12260 from HHammond/style-remove-col-index-none and squashes the following commits: 48c2f4c [Henry Hammond] BUG: Ignore style column headers when None a15248a [Tom Augspurger] ENH: display_format for style
Partial solution for #11655 (Conditional HTML styling hides MultiIndex structure) and #11610 (Followup to Conditional HTML Styling).
The Style API is inconsistent with
DataFrame.to_html()
when printing index names. Currently the style API doesn't print any index names butto_html
and the standard notebook repr functions do.This PR adds a row for index headings in the
Styler._translate
method. This PR does not cause multi-index rownames to span multiple rows, but I can work on adding that if people want.Reproducing Output:
Current Output

##### Patched Output:
## TODO: - [X] Add Tests