Skip to content

Commit 773d78d

Browse files
DOC: fix EX03 errors in docstrings - pandas.io.formats.style.Styler: set_tooltips, set_uuid, pipe, highlight_between (#56901)
1 parent 42d40af commit 773d78d

File tree

2 files changed

+17
-18
lines changed

2 files changed

+17
-18
lines changed

ci/code_checks.sh

-4
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
8484
pandas.io.formats.style.Styler.apply_index \
8585
pandas.io.formats.style.Styler.map_index \
8686
pandas.io.formats.style.Styler.format \
87-
pandas.io.formats.style.Styler.set_tooltips \
88-
pandas.io.formats.style.Styler.set_uuid \
89-
pandas.io.formats.style.Styler.pipe \
90-
pandas.io.formats.style.Styler.highlight_between \
9187
pandas.io.formats.style.Styler.highlight_quantile \
9288
pandas.io.formats.style.Styler.background_gradient \
9389
pandas.io.formats.style.Styler.text_gradient \

pandas/io/formats/style.py

+17-14
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ def set_tooltips(
476476
477477
>>> df = pd.DataFrame(data=[[0, 1], [2, 3]])
478478
>>> ttips = pd.DataFrame(
479-
... data=[["Min", ""], [np.nan, "Max"]], columns=df.columns, index=df.index
479+
... data=[["Min", ""], [np.nan, "Max"]], columns=df.columns, index=df.index
480480
... )
481481
>>> s = df.style.set_tooltips(ttips).to_html()
482482
@@ -486,7 +486,8 @@ def set_tooltips(
486486
... ('visibility', 'hidden'),
487487
... ('position', 'absolute'),
488488
... ('z-index', 1)]) # doctest: +SKIP
489-
>>> df.style.set_tooltips(ttips, css_class='tt-add',
489+
>>> df.style.set_tooltips(
490+
... ttips, css_class='tt-add',
490491
... props='visibility:hidden; position:absolute; z-index:1;')
491492
... # doctest: +SKIP
492493
"""
@@ -2305,8 +2306,8 @@ def set_uuid(self, uuid: str) -> Styler:
23052306
23062307
To add a title to column `c1`, its `id` is T_20a7d_level0_col0:
23072308
2308-
>>> df.style.set_uuid("T_20a7d_level0_col0")
2309-
... .set_caption("Test") # doctest: +SKIP
2309+
>>> df.style.set_uuid("T_20a7d_level0_col0").set_caption("Test")
2310+
... # doctest: +SKIP
23102311
23112312
Please see:
23122313
`Table visualization <../../user_guide/style.ipynb>`_ for more examples.
@@ -3418,21 +3419,23 @@ def highlight_between(
34183419
and ``right`` for each column individually
34193420
34203421
>>> df.style.highlight_between(left=[1.4, 2.4, 3.4], right=[1.6, 2.6, 3.6],
3421-
... axis=1, color="#fffd75") # doctest: +SKIP
3422+
... axis=1, color="#fffd75") # doctest: +SKIP
34223423
34233424
.. figure:: ../../_static/style/hbetw_seq.png
34243425
34253426
Using ``axis=None`` and providing the ``left`` argument as an array that
34263427
matches the input DataFrame, with a constant ``right``
34273428
3428-
>>> df.style.highlight_between(left=[[2,2,3],[2,2,3],[3,3,3]], right=3.5,
3429+
>>> df.style.highlight_between(
3430+
... left=[[2, 2, 3], [2, 2, 3], [3, 3, 3]], right=3.5,
34293431
... axis=None, color="#fffd75") # doctest: +SKIP
34303432
34313433
.. figure:: ../../_static/style/hbetw_axNone.png
34323434
34333435
Using ``props`` instead of default background coloring
34343436
3435-
>>> df.style.highlight_between(left=1.5, right=3.5,
3437+
>>> df.style.highlight_between(
3438+
... left=1.5, right=3.5,
34363439
... props='font-weight:bold;color:#e83e8c') # doctest: +SKIP
34373440
34383441
.. figure:: ../../_static/style/hbetw_props.png
@@ -3699,10 +3702,10 @@ def pipe(
36993702
can be easily applied to a generic styler in a single ``pipe`` call.
37003703
37013704
>>> def some_highlights(styler, min_color="red", max_color="blue"):
3702-
... styler.highlight_min(color=min_color, axis=None)
3703-
... styler.highlight_max(color=max_color, axis=None)
3704-
... styler.highlight_null()
3705-
... return styler
3705+
... styler.highlight_min(color=min_color, axis=None)
3706+
... styler.highlight_max(color=max_color, axis=None)
3707+
... styler.highlight_null()
3708+
... return styler
37063709
>>> df = pd.DataFrame([[1, 2, 3, pd.NA], [pd.NA, 4, 5, 6]], dtype="Int64")
37073710
>>> df.style.pipe(some_highlights, min_color="green") # doctest: +SKIP
37083711
@@ -3712,8 +3715,8 @@ def pipe(
37123715
methods as if applying the underlying highlighters directly.
37133716
37143717
>>> (df.style.format("{:.1f}")
3715-
... .pipe(some_highlights, min_color="green")
3716-
... .highlight_between(left=2, right=5)) # doctest: +SKIP
3718+
... .pipe(some_highlights, min_color="green")
3719+
... .highlight_between(left=2, right=5)) # doctest: +SKIP
37173720
37183721
.. figure:: ../../_static/style/df_pipe_hl2.png
37193722
@@ -3733,7 +3736,7 @@ def pipe(
37333736
>>> def highlight_last_level(styler):
37343737
... return styler.apply_index(
37353738
... lambda v: "background-color: pink; color: yellow", axis="columns",
3736-
... level=styler.columns.nlevels-1
3739+
... level=styler.columns.nlevels - 1
37373740
... ) # doctest: +SKIP
37383741
>>> df.columns = pd.MultiIndex.from_product([["A", "B"], ["X", "Y"]])
37393742
>>> df.style.pipe(highlight_last_level) # doctest: +SKIP

0 commit comments

Comments
 (0)