-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
ENH: Styler.apply_index
and Styler.applymap_index
for conditional formatting of column/index headers
#41893
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
ENH: Styler.apply_index
and Styler.applymap_index
for conditional formatting of column/index headers
#41893
Conversation
Styler
apply
and applymap
over the index instead of the dataStyler
apply
and applymap
over the index instead of the data
Styler
apply
and applymap
over the index instead of the dataStyler
apply
and applymap
over the index instead of the data
Styler
apply
and applymap
over the index instead of the dataStyler.apply_header
and Styler.applymap_header
for conditional formatting of column/index headers
…x_specific # Conflicts: # doc/source/reference/style.rst # pandas/io/formats/style_render.py # pandas/tests/io/formats/style/test_html.py
…x_specific # Conflicts: # pandas/tests/io/formats/style/test_style.py
…x_specific # Conflicts: # doc/source/whatsnew/v1.4.0.rst # pandas/tests/io/formats/style/test_style.py
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.
wouldn't apply_axis be more appropriate? e.g. don't see _header anywhere else in the codebase
do we need both (i get that we have symmetry, but is this overkill)?
i came up with 'header' becuase in the HTML that styler renders the index and column header cells are I'm not tied to the name but
|
…x_specific # Conflicts: # doc/source/whatsnew/v1.4.0.rst # pandas/tests/io/formats/style/test_html.py
…x_specific # Conflicts: # doc/source/whatsnew/v1.4.0.rst # pandas/io/formats/style_render.py # pandas/tests/io/formats/style/test_style.py
…x_specific # Conflicts: # pandas/tests/io/formats/style/test_style.py
Styler.apply_header
and Styler.applymap_header
for conditional formatting of column/index headersStyler.apply_index
and Styler.applymap_index
for conditional formatting of column/index headers
@@ -38,6 +38,7 @@ Other enhancements | |||
- :meth:`Series.ewm`, :meth:`DataFrame.ewm`, now support a ``method`` argument with a ``'table'`` option that performs the windowing operation over an entire :class:`DataFrame`. See :ref:`Window Overview <window.overview>` for performance and functional benefits (:issue:`42273`) | |||
- Added ``sparse_index`` and ``sparse_columns`` keyword arguments to :meth:`.Styler.to_html` (:issue:`41946`) | |||
- Added keyword argument ``environment`` to :meth:`.Styler.to_latex` also allowing a specific "longtable" entry with a separate jinja2 template (:issue:`41866`) | |||
- :meth:`.Styler.apply_index` and :meth:`.Styler.applymap_index` added to allow conditional styling of index and column header values (:issue:`41893`) |
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 creating a styler sub-section in other enhancements (followon)
thanks @attack68 very nice! |
… formatting of column/index headers (pandas-dev#41893)
Checks an item on #41648 and #41693
Currently Styler has the
apply
andapplymap
methods to perform conditional styling on the data elements.Recent additions to
Styler.set_table_styles
allows styling of index and column headers if the key-labels are directly specified. But this solution cannot work with LaTeX, nor excel output, and is obviously not conditionally applied.This PR adds the mechanics to perform conditional styling on per level index labels
Follow-ons are:
Styler.apply(map)_index
made compatible withStyler.to_latex
#41993)Styler.apply(map)_index
made compatible withStyler.to_excel
#41995)