-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
ENH: Styler.highlight_null
can accepts subset
argument
#31350
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
Changes from 2 commits
b002086
e22a656
2f1ea73
1075f0b
99715cb
d5beab0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -1006,19 +1006,23 @@ def hide_columns(self, subset) -> "Styler": | |||||||||||||||||
def _highlight_null(v, null_color: str) -> str: | ||||||||||||||||||
return f"background-color: {null_color}" if pd.isna(v) else "" | ||||||||||||||||||
|
||||||||||||||||||
def highlight_null(self, null_color: str = "red") -> "Styler": | ||||||||||||||||||
def highlight_null(self, null_color: str = "red", subset=None) -> "Styler": | ||||||||||||||||||
""" | ||||||||||||||||||
Shade the background ``null_color`` for missing values. | ||||||||||||||||||
|
||||||||||||||||||
Parameters | ||||||||||||||||||
---------- | ||||||||||||||||||
null_color : str | ||||||||||||||||||
null_color : str, default 'red' | ||||||||||||||||||
subset : IndexSlice, default None | ||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This isn't an IndexSlice right? Just a label or list of labels? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is an IndexSlice, since it calls < code > pandas/pandas/io/formats/style.py Lines 729 to 736 in e22a656
< proof > There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The test case here though is not for an IndexSlice rather a list of labels. I think for a natural API should go with Label / Sequence of Labels as mentioned above There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you update this to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sure. |
||||||||||||||||||
A valid slice for ``data`` to limit the style application to. | ||||||||||||||||||
|
||||||||||||||||||
.. versionadded:: 1.1.0 | ||||||||||||||||||
|
||||||||||||||||||
Returns | ||||||||||||||||||
------- | ||||||||||||||||||
self : Styler | ||||||||||||||||||
""" | ||||||||||||||||||
self.applymap(self._highlight_null, null_color=null_color) | ||||||||||||||||||
self.applymap(self._highlight_null, null_color=null_color, subset=subset) | ||||||||||||||||||
return self | ||||||||||||||||||
|
||||||||||||||||||
def background_gradient( | ||||||||||||||||||
|
Uh oh!
There was an error while loading. Please reload this page.