Skip to content

DOC CLN: use color shared doc string #45251

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

Merged
merged 4 commits into from
Jan 12, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 23 additions & 21 deletions pandas/io/formats/style.py
Original file line number Diff line number Diff line change
Expand Up @@ -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[<subset>]`, or, in the case of a 1d input
or single key, to `DataFrame.loc[:, <subset>]` 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."""

#
###
Expand Down Expand Up @@ -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
Expand All @@ -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,
Expand All @@ -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
Expand All @@ -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,
Expand All @@ -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
Expand All @@ -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,
Expand All @@ -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.
Expand All @@ -3253,6 +3254,7 @@ def highlight_between(
inclusive : {'both', 'neither', 'left', 'right'}
Identify whether bounds are closed or open.
%(props)s

Returns
-------
self : Styler
Expand Down Expand Up @@ -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,
Expand All @@ -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.
Expand All @@ -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
Expand Down