Skip to content

DOC: fix EX03 errors in docstrings - pandas.io.formats.style.Styler: set_tooltips, set_uuid, pipe, highlight_between #56901

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 1 commit into from
Jan 16, 2024
Merged
Show file tree
Hide file tree
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
4 changes: 0 additions & 4 deletions ci/code_checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
pandas.io.formats.style.Styler.apply_index \
pandas.io.formats.style.Styler.map_index \
pandas.io.formats.style.Styler.format \
pandas.io.formats.style.Styler.set_tooltips \
pandas.io.formats.style.Styler.set_uuid \
pandas.io.formats.style.Styler.pipe \
pandas.io.formats.style.Styler.highlight_between \
pandas.io.formats.style.Styler.highlight_quantile \
pandas.io.formats.style.Styler.background_gradient \
pandas.io.formats.style.Styler.text_gradient \
Expand Down
31 changes: 17 additions & 14 deletions pandas/io/formats/style.py
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ def set_tooltips(

>>> df = pd.DataFrame(data=[[0, 1], [2, 3]])
>>> ttips = pd.DataFrame(
... data=[["Min", ""], [np.nan, "Max"]], columns=df.columns, index=df.index
... data=[["Min", ""], [np.nan, "Max"]], columns=df.columns, index=df.index
... )
>>> s = df.style.set_tooltips(ttips).to_html()

Expand All @@ -486,7 +486,8 @@ def set_tooltips(
... ('visibility', 'hidden'),
... ('position', 'absolute'),
... ('z-index', 1)]) # doctest: +SKIP
>>> df.style.set_tooltips(ttips, css_class='tt-add',
>>> df.style.set_tooltips(
... ttips, css_class='tt-add',
... props='visibility:hidden; position:absolute; z-index:1;')
... # doctest: +SKIP
"""
Expand Down Expand Up @@ -2305,8 +2306,8 @@ def set_uuid(self, uuid: str) -> Styler:

To add a title to column `c1`, its `id` is T_20a7d_level0_col0:

>>> df.style.set_uuid("T_20a7d_level0_col0")
... .set_caption("Test") # doctest: +SKIP
>>> df.style.set_uuid("T_20a7d_level0_col0").set_caption("Test")
... # doctest: +SKIP

Please see:
`Table visualization <../../user_guide/style.ipynb>`_ for more examples.
Expand Down Expand Up @@ -3418,21 +3419,23 @@ def highlight_between(
and ``right`` for each column individually

>>> df.style.highlight_between(left=[1.4, 2.4, 3.4], right=[1.6, 2.6, 3.6],
... axis=1, color="#fffd75") # doctest: +SKIP
... axis=1, color="#fffd75") # doctest: +SKIP

.. figure:: ../../_static/style/hbetw_seq.png

Using ``axis=None`` and providing the ``left`` argument as an array that
matches the input DataFrame, with a constant ``right``

>>> df.style.highlight_between(left=[[2,2,3],[2,2,3],[3,3,3]], right=3.5,
>>> df.style.highlight_between(
... left=[[2, 2, 3], [2, 2, 3], [3, 3, 3]], right=3.5,
... axis=None, color="#fffd75") # doctest: +SKIP

.. figure:: ../../_static/style/hbetw_axNone.png

Using ``props`` instead of default background coloring

>>> df.style.highlight_between(left=1.5, right=3.5,
>>> df.style.highlight_between(
... left=1.5, right=3.5,
... props='font-weight:bold;color:#e83e8c') # doctest: +SKIP

.. figure:: ../../_static/style/hbetw_props.png
Expand Down Expand Up @@ -3699,10 +3702,10 @@ def pipe(
can be easily applied to a generic styler in a single ``pipe`` call.

>>> def some_highlights(styler, min_color="red", max_color="blue"):
... styler.highlight_min(color=min_color, axis=None)
... styler.highlight_max(color=max_color, axis=None)
... styler.highlight_null()
... return styler
... styler.highlight_min(color=min_color, axis=None)
... styler.highlight_max(color=max_color, axis=None)
... styler.highlight_null()
... return styler
>>> df = pd.DataFrame([[1, 2, 3, pd.NA], [pd.NA, 4, 5, 6]], dtype="Int64")
>>> df.style.pipe(some_highlights, min_color="green") # doctest: +SKIP

Expand All @@ -3712,8 +3715,8 @@ def pipe(
methods as if applying the underlying highlighters directly.

>>> (df.style.format("{:.1f}")
... .pipe(some_highlights, min_color="green")
... .highlight_between(left=2, right=5)) # doctest: +SKIP
... .pipe(some_highlights, min_color="green")
... .highlight_between(left=2, right=5)) # doctest: +SKIP

.. figure:: ../../_static/style/df_pipe_hl2.png

Expand All @@ -3733,7 +3736,7 @@ def pipe(
>>> def highlight_last_level(styler):
... return styler.apply_index(
... lambda v: "background-color: pink; color: yellow", axis="columns",
... level=styler.columns.nlevels-1
... level=styler.columns.nlevels - 1
... ) # doctest: +SKIP
>>> df.columns = pd.MultiIndex.from_product([["A", "B"], ["X", "Y"]])
>>> df.style.pipe(highlight_last_level) # doctest: +SKIP
Expand Down