Highlight the maximum with a style. Parameters ---------- subset : label, array-like, IndexSlice, optional A valid 2d input to `DataFrame.loc[<subset>]`, or, in the case of a 1d input or single key, to `DataFrame.loc[:, <subset>]` where the c
(
self,
subset: Subset | None = None,
color: str = "yellow",
axis: Axis | None = 0,
props: str | None = None,
)
| 3588 | return self.apply(f, axis=None, subset=subset, props=props) |
| 3589 | |
| 3590 | def highlight_max( |
| 3591 | self, |
| 3592 | subset: Subset | None = None, |
| 3593 | color: str = "yellow", |
| 3594 | axis: Axis | None = 0, |
| 3595 | props: str | None = None, |
| 3596 | ) -> Styler: |
| 3597 | """ |
| 3598 | Highlight the maximum with a style. |
| 3599 | |
| 3600 | Parameters |
| 3601 | ---------- |
| 3602 | subset : label, array-like, IndexSlice, optional |
| 3603 | A valid 2d input to `DataFrame.loc[<subset>]`, or, in the case of a 1d input |
| 3604 | or single key, to `DataFrame.loc[:, <subset>]` where the columns are |
| 3605 | prioritised, to limit ``data`` to *before* applying the function. |
| 3606 | color : str, default 'yellow' |
| 3607 | Background color to use for highlighting. |
| 3608 | axis : {0 or 'index', 1 or 'columns', None}, default 0 |
| 3609 | Apply to each column (``axis=0`` or ``'index'``), to each row |
| 3610 | (``axis=1`` or ``'columns'``), or to the entire DataFrame at once |
| 3611 | with ``axis=None``. |
| 3612 | props : str, default None |
| 3613 | CSS properties to use for highlighting. If ``props`` is given, ``color`` |
| 3614 | is not used. |
| 3615 | |
| 3616 | Returns |
| 3617 | ------- |
| 3618 | Styler |
| 3619 | Instance of class where max value is highlighted in given style. |
| 3620 | |
| 3621 | See Also |
| 3622 | -------- |
| 3623 | Styler.highlight_null: Highlight missing values with a style. |
| 3624 | Styler.highlight_min: Highlight the minimum with a style. |
| 3625 | Styler.highlight_between: Highlight a defined range with a style. |
| 3626 | Styler.highlight_quantile: Highlight values defined by a quantile with a style. |
| 3627 | |
| 3628 | Examples |
| 3629 | -------- |
| 3630 | >>> df = pd.DataFrame({"A": [2, 1], "B": [3, 4]}) |
| 3631 | >>> df.style.highlight_max(color="yellow") # doctest: +SKIP |
| 3632 | |
| 3633 | Please see: |
| 3634 | `Table Visualization <../../user_guide/style.ipynb>`_ for more examples. |
| 3635 | """ |
| 3636 | |
| 3637 | if props is None: |
| 3638 | props = f"background-color: {color};" |
| 3639 | return self.apply( |
| 3640 | partial(_highlight_value, op="max"), |
| 3641 | axis=axis, |
| 3642 | subset=subset, |
| 3643 | props=props, |
| 3644 | ) |
| 3645 | |
| 3646 | def highlight_min( |
| 3647 | self, |