diff --git a/pandas/io/formats/style.py b/pandas/io/formats/style.py index c8f65c6a2b580..87d4bbcc38373 100644 --- a/pandas/io/formats/style.py +++ b/pandas/io/formats/style.py @@ -85,18 +85,17 @@ def _mpl(func: Callable): #### # Shared Doc Strings -subset = """ - subset : label, array-like, IndexSlice, optional +subset = """subset : label, array-like, IndexSlice, optional A valid 2d input to `DataFrame.loc[]`, or, in the case of a 1d input or single key, to `DataFrame.loc[:, ]` where the columns are - prioritised, to limit ``data`` to *before* applying the function. -""" + prioritised, to limit ``data`` to *before* applying the function.""" -props = """ - props : str, default None - CSS properties to use for highlighting. If ``props`` is given, ``color`` - is not used. -""" +props = """props : str, default None + CSS properties to use for highlighting. If ``props`` is given, ``color`` + is not used.""" + +color = """color : str, default 'yellow' + Background color to use for highlighting.""" # ### @@ -3111,8 +3110,11 @@ def highlight_null( ---------- null_color : str, default 'red' %(subset)s + .. versionadded:: 1.1.0 + %(props)s + .. versionadded:: 1.3.0 Returns @@ -3134,7 +3136,7 @@ def f(data: DataFrame, props: str) -> np.ndarray: props = f"background-color: {null_color};" return self.apply(f, axis=None, subset=subset, props=props) - @Substitution(subset=subset, props=props) + @Substitution(subset=subset, color=color, props=props) def highlight_max( self, subset: Subset | None = None, @@ -3148,13 +3150,13 @@ def highlight_max( Parameters ---------- %(subset)s - color : str, default 'yellow' - Background color to use for highlighting. + %(color)s axis : {0 or 'index', 1 or 'columns', None}, default 0 Apply to each column (``axis=0`` or ``'index'``), to each row (``axis=1`` or ``'columns'``), or to the entire DataFrame at once with ``axis=None``. %(props)s + .. versionadded:: 1.3.0 Returns @@ -3178,7 +3180,7 @@ def highlight_max( props=props, ) - @Substitution(subset=subset, props=props) + @Substitution(subset=subset, color=color, props=props) def highlight_min( self, subset: Subset | None = None, @@ -3192,13 +3194,13 @@ def highlight_min( Parameters ---------- %(subset)s - color : str, default 'yellow' - Background color to use for highlighting. + %(color)s axis : {0 or 'index', 1 or 'columns', None}, default 0 Apply to each column (``axis=0`` or ``'index'``), to each row (``axis=1`` or ``'columns'``), or to the entire DataFrame at once with ``axis=None``. %(props)s + .. versionadded:: 1.3.0 Returns @@ -3222,7 +3224,7 @@ def highlight_min( props=props, ) - @Substitution(subset=subset, props=props) + @Substitution(subset=subset, color=color, props=props) def highlight_between( self, subset: Subset | None = None, @@ -3241,8 +3243,7 @@ def highlight_between( Parameters ---------- %(subset)s - color : str, default 'yellow' - Background color to use for highlighting. + %(color)s axis : {0 or 'index', 1 or 'columns', None}, default 0 If ``left`` or ``right`` given as sequence, axis along which to apply those boundaries. See examples. @@ -3253,6 +3254,7 @@ def highlight_between( inclusive : {'both', 'neither', 'left', 'right'} Identify whether bounds are closed or open. %(props)s + Returns ------- self : Styler @@ -3326,7 +3328,7 @@ def highlight_between( inclusive=inclusive, ) - @Substitution(subset=subset, props=props) + @Substitution(subset=subset, color=color, props=props) def highlight_quantile( self, subset: Subset | None = None, @@ -3346,8 +3348,7 @@ def highlight_quantile( Parameters ---------- %(subset)s - color : str, default 'yellow' - Background color to use for highlighting. + %(color)s axis : {0 or 'index', 1 or 'columns', None}, default 0 Axis along which to determine and highlight quantiles. If ``None`` quantiles are measured over the entire DataFrame. See examples. @@ -3361,6 +3362,7 @@ def highlight_quantile( inclusive : {'both', 'neither', 'left', 'right'} Identify whether quantile bounds are closed or open. %(props)s + Returns ------- self : Styler