-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: styler multiindex hiding indexes and columns alignment #43649
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
BUG: styler multiindex hiding indexes and columns alignment #43649
Conversation
pandas/io/formats/style_render.py
Outdated
) | ||
for c in range(max_cols) | ||
] | ||
if r not in self.hidden_rows: |
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.
only added this line to this method and all code below it was indended one tab.
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.
might be worth splitting up translate_body to some function calls to make it simpler to grok (future)
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.
yeh agreed, i already did this once splitting _translate into header and body and now it has acquired some more stuff, like min/mix limiting etc.. will add an issue
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.
i will finish making this clean up after #43686
for r, row in enumerate(d["body"]): | ||
index_levels = self.data.index.nlevels | ||
for r, row in zip( | ||
[r for r in range(len(self.data.index)) if r not in self.hidden_rows], |
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.
might be worth a property to have this
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.
this is only needed for latex, so for most cases not necessary and might add additional overhead for large HTML (usually latex tables quite a lot smaller)
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.
took a second look here. d
is dynamic so a class property won't work. think the comment is sufficient.
…ndex_hiding # Conflicts: # pandas/tests/io/formats/style/test_to_latex.py
…ding # Conflicts: # pandas/io/formats/style_render.py # pandas/tests/io/formats/style/test_html.py
because of moving the hiding functions to outer loop:
|
…ding # Conflicts: # pandas/tests/io/formats/style/test_style.py
…classes # Conflicts: # doc/source/user_guide/style.ipynb
…ndex_hiding # Conflicts: # doc/source/user_guide/style.ipynb # doc/source/whatsnew/v1.4.0.rst # pandas/io/formats/style.py # pandas/io/formats/style_render.py # pandas/tests/io/formats/style/test_html.py
…ndex_hiding # Conflicts: # doc/source/user_guide/style.ipynb # doc/source/whatsnew/v1.4.0.rst # pandas/io/formats/style.py # pandas/io/formats/style_render.py # pandas/tests/io/formats/style/test_html.py
thanks! |
Follows #43686
styler.to_latex
does hide rows afterhide_index([subset])
#43637hide_index
#43703levels
which is a new feature in 1.4.0).This PR has two parts:
The key change made here was to add a single line:
if r not in self.hidden_rows:
in the loop, and in_translate_latex
update for the new object structure that is input to it.And tests were update and comprehensive tests for the issues added.