Skip to content

Commit 54d43a8

Browse files
committed
DOC: all pandas.io.formats.style.Styler docstring validation errors fixed
1 parent 360597c commit 54d43a8

File tree

2 files changed

+104
-31
lines changed

2 files changed

+104
-31
lines changed

ci/code_checks.sh

-28
Original file line numberDiff line numberDiff line change
@@ -305,34 +305,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
305305
-i "pandas.errors.UnsupportedFunctionCall SA01" \
306306
-i "pandas.errors.ValueLabelTypeMismatch SA01" \
307307
-i "pandas.infer_freq SA01" \
308-
-i "pandas.io.formats.style.Styler.apply RT03" \
309-
-i "pandas.io.formats.style.Styler.apply_index RT03" \
310-
-i "pandas.io.formats.style.Styler.background_gradient RT03" \
311-
-i "pandas.io.formats.style.Styler.bar RT03,SA01" \
312-
-i "pandas.io.formats.style.Styler.clear SA01" \
313-
-i "pandas.io.formats.style.Styler.concat RT03,SA01" \
314-
-i "pandas.io.formats.style.Styler.export RT03" \
315-
-i "pandas.io.formats.style.Styler.from_custom_template SA01" \
316-
-i "pandas.io.formats.style.Styler.hide RT03,SA01" \
317-
-i "pandas.io.formats.style.Styler.highlight_between RT03" \
318-
-i "pandas.io.formats.style.Styler.highlight_max RT03" \
319-
-i "pandas.io.formats.style.Styler.highlight_min RT03" \
320-
-i "pandas.io.formats.style.Styler.highlight_null RT03" \
321-
-i "pandas.io.formats.style.Styler.highlight_quantile RT03" \
322-
-i "pandas.io.formats.style.Styler.map RT03" \
323-
-i "pandas.io.formats.style.Styler.map_index RT03" \
324-
-i "pandas.io.formats.style.Styler.set_caption RT03,SA01" \
325-
-i "pandas.io.formats.style.Styler.set_properties RT03,SA01" \
326-
-i "pandas.io.formats.style.Styler.set_sticky RT03,SA01" \
327-
-i "pandas.io.formats.style.Styler.set_table_attributes PR07,RT03" \
328-
-i "pandas.io.formats.style.Styler.set_table_styles RT03" \
329-
-i "pandas.io.formats.style.Styler.set_td_classes RT03" \
330-
-i "pandas.io.formats.style.Styler.set_tooltips RT03,SA01" \
331-
-i "pandas.io.formats.style.Styler.set_uuid PR07,RT03,SA01" \
332-
-i "pandas.io.formats.style.Styler.text_gradient RT03" \
333-
-i "pandas.io.formats.style.Styler.to_excel PR01" \
334-
-i "pandas.io.formats.style.Styler.to_string SA01" \
335-
-i "pandas.io.formats.style.Styler.use RT03" \
336308
-i "pandas.io.json.build_table_schema PR07,RT03,SA01" \
337309
-i "pandas.io.stata.StataReader.data_label SA01" \
338310
-i "pandas.io.stata.StataReader.value_labels RT03,SA01" \

pandas/io/formats/style.py

+104-3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import copy
88
from functools import partial
99
import operator
10+
import textwrap
1011
from typing import (
1112
TYPE_CHECKING,
1213
overload,
@@ -306,6 +307,12 @@ def concat(self, other: Styler) -> Styler:
306307
Returns
307308
-------
308309
Styler
310+
Instance of class with specified Styler appended.
311+
312+
See Also
313+
--------
314+
Styler.clear : Reset the ``Styler``, removing any previously applied styles.
315+
Styler.export : Export the styles applied to the current Styler.
309316
310317
Notes
311318
-----
@@ -447,6 +454,15 @@ def set_tooltips(
447454
Returns
448455
-------
449456
Styler
457+
Instance of class with DataFrame set for strings on ``Styler``
458+
generating ``:hover`` tooltips.
459+
460+
See Also
461+
--------
462+
Styler.set_table_attributes : Set the table attributes added to the
463+
``<table>`` HTML element.
464+
Styler.set_table_styles : Set the table styles included within the
465+
``<style>`` HTML element.
450466
451467
Notes
452468
-----
@@ -537,7 +553,14 @@ def set_tooltips(
537553
klass="Styler",
538554
storage_options=_shared_docs["storage_options"],
539555
storage_options_versionadded="1.5.0",
540-
extra_parameters="",
556+
extra_parameters=textwrap.dedent(
557+
"""\
558+
encoding : str or None, default None
559+
Unused parameter, present for compatibility.
560+
verbose : str, default True
561+
Optional unused parameter, present for compatibility.
562+
"""
563+
),
541564
)
542565
def to_excel(
543566
self,
@@ -553,11 +576,11 @@ def to_excel(
553576
startcol: int = 0,
554577
engine: str | None = None,
555578
merge_cells: ExcelWriterMergeCells = True,
556-
encoding: str | None = None,
557579
inf_rep: str = "inf",
558-
verbose: bool = True,
559580
freeze_panes: tuple[int, int] | None = None,
560581
storage_options: StorageOptions | None = None,
582+
encoding: str | None = None,
583+
verbose: bool = True,
561584
) -> None:
562585
from pandas.io.formats.excel import ExcelFormatter
563586

@@ -1456,6 +1479,10 @@ def to_string(
14561479
str or None
14571480
If `buf` is None, returns the result as a string. Otherwise returns `None`.
14581481
1482+
See Also
1483+
--------
1484+
DataFrame.to_string : Render a DataFrame to a console-friendly tabular output.
1485+
14591486
Examples
14601487
--------
14611488
>>> df = pd.DataFrame({"A": [1, 2], "B": [3, 4]})
@@ -1495,6 +1522,8 @@ def set_td_classes(self, classes: DataFrame) -> Styler:
14951522
Returns
14961523
-------
14971524
Styler
1525+
Instance of class with ``class`` attribute set for ``<td>``
1526+
HTML elements.
14981527
14991528
See Also
15001529
--------
@@ -1700,6 +1729,14 @@ def clear(self) -> None:
17001729
17011730
Returns None.
17021731
1732+
See Also
1733+
--------
1734+
Styler.apply : Apply a CSS-styling function column-wise, row-wise,
1735+
or table-wise.
1736+
Styler.export : Export the styles applied to the current Styler.
1737+
Styler.map : Apply a CSS-styling function elementwise.
1738+
Styler.use : Set the styles on the current Styler.
1739+
17031740
Examples
17041741
--------
17051742
>>> df = pd.DataFrame({"A": [1, 2], "B": [3, np.nan]})
@@ -1821,6 +1858,7 @@ def apply(
18211858
Returns
18221859
-------
18231860
Styler
1861+
Instance of class with CSS applied to its HTML representation.
18241862
18251863
See Also
18261864
--------
@@ -1941,6 +1979,7 @@ def apply_index(
19411979
Returns
19421980
-------
19431981
Styler
1982+
Instance of class with CSS applied to its HTML representation.
19441983
19451984
See Also
19461985
--------
@@ -2041,6 +2080,7 @@ def map(self, func: Callable, subset: Subset | None = None, **kwargs) -> Styler:
20412080
Returns
20422081
-------
20432082
Styler
2083+
Instance of class with CSS-styling function applied elementwise.
20442084
20452085
See Also
20462086
--------
@@ -2093,10 +2133,12 @@ def set_table_attributes(self, attributes: str) -> Styler:
20932133
Parameters
20942134
----------
20952135
attributes : str
2136+
Table attributes to be added to the ``<table>`` HTML element.
20962137
20972138
Returns
20982139
-------
20992140
Styler
2141+
Instance of class with specified table attributes set.
21002142
21012143
See Also
21022144
--------
@@ -2123,6 +2165,7 @@ def export(self) -> dict[str, Any]:
21232165
Returns
21242166
-------
21252167
dict
2168+
Contains data-independent (exportable) styles applied to current Styler.
21262169
21272170
See Also
21282171
--------
@@ -2199,6 +2242,7 @@ def use(self, styles: dict[str, Any]) -> Styler:
21992242
Returns
22002243
-------
22012244
Styler
2245+
Instance of class with defined styler attributes added.
22022246
22032247
See Also
22042248
--------
@@ -2246,10 +2290,19 @@ def set_uuid(self, uuid: str) -> Styler:
22462290
Parameters
22472291
----------
22482292
uuid : str
2293+
The uuid to be applied to ``id`` attributes of HTML elements.
22492294
22502295
Returns
22512296
-------
22522297
Styler
2298+
Instance of class with specified uuid for `id` attributes set.
2299+
2300+
See Also
2301+
--------
2302+
Styler.set_caption : Set the text added to a ``<caption>`` HTML element.
2303+
Styler.set_td_classes : Set the ``class`` attribute of ``<td>`` HTML elements.
2304+
Styler.set_tooltips : Set the DataFrame of strings on ``Styler`` generating
2305+
``:hover`` tooltips.
22532306
22542307
Notes
22552308
-----
@@ -2290,6 +2343,14 @@ def set_caption(self, caption: str | tuple | list) -> Styler:
22902343
Returns
22912344
-------
22922345
Styler
2346+
Instance of class with text set for ``<caption>`` HTML element.
2347+
2348+
See Also
2349+
--------
2350+
Styler.set_td_classes : Set the ``class`` attribute of ``<td>`` HTML elements.
2351+
Styler.set_tooltips : Set the DataFrame of strings on ``Styler`` generating
2352+
``:hover`` tooltips.
2353+
Styler.set_uuid : Set the uuid applied to ``id`` attributes of HTML elements.
22932354
22942355
Examples
22952356
--------
@@ -2336,6 +2397,13 @@ def set_sticky(
23362397
Returns
23372398
-------
23382399
Styler
2400+
Instance of class with CSS set for permanently displaying headers
2401+
in scrolling frame.
2402+
2403+
See Also
2404+
--------
2405+
Styler.set_properties : Set defined CSS-properties to each ``<td>``
2406+
HTML element for the given subset.
23392407
23402408
Notes
23412409
-----
@@ -2496,6 +2564,7 @@ def set_table_styles(
24962564
Returns
24972565
-------
24982566
Styler
2567+
Instance of class with specified table styles set.
24992568
25002569
See Also
25012570
--------
@@ -2627,6 +2696,13 @@ def hide(
26272696
Returns
26282697
-------
26292698
Styler
2699+
Instance of class with specified headers/rows/columns hidden from display.
2700+
2701+
See Also
2702+
--------
2703+
Styler.apply : Apply a CSS-styling function column-wise, row-wise,
2704+
or table-wise.
2705+
Styler.map : Apply a CSS-styling function elementwise.
26302706
26312707
Notes
26322708
-----
@@ -2865,6 +2941,7 @@ def background_gradient(
28652941
Returns
28662942
-------
28672943
Styler
2944+
Instance of class with {name} colored in gradient style.
28682945
28692946
See Also
28702947
--------
@@ -3002,6 +3079,13 @@ def set_properties(self, subset: Subset | None = None, **kwargs) -> Styler:
30023079
Returns
30033080
-------
30043081
Styler
3082+
Instance of class with CSS-properties set for each ``<td>`` HTML element
3083+
in the given subset
3084+
3085+
See Also
3086+
--------
3087+
Styler.set_sticky : Add CSS to permanently display the index or column
3088+
headers in a scrolling frame.
30053089
30063090
Notes
30073091
-----
@@ -3099,6 +3183,13 @@ def bar(
30993183
Returns
31003184
-------
31013185
Styler
3186+
Contains list-like attribute with bar chart data as formatted CSS.
3187+
3188+
See Also
3189+
--------
3190+
PlotAccessor.bar : Vertical bar plot.
3191+
PlotAccessor.line : Plot Series or DataFrame as lines.
3192+
PlotAccessor.pie : Generate a pie plot.
31023193
31033194
Notes
31043195
-----
@@ -3177,6 +3268,7 @@ def highlight_null(
31773268
Returns
31783269
-------
31793270
Styler
3271+
Instance of class where null values are highlighted with given style.
31803272
31813273
See Also
31823274
--------
@@ -3231,6 +3323,7 @@ def highlight_max(
32313323
Returns
32323324
-------
32333325
Styler
3326+
Instance of class where max value is highlighted in given style.
32343327
32353328
See Also
32363329
--------
@@ -3287,6 +3380,7 @@ def highlight_min(
32873380
Returns
32883381
-------
32893382
Styler
3383+
Instance of class where min value is highlighted in given style.
32903384
32913385
See Also
32923386
--------
@@ -3351,6 +3445,7 @@ def highlight_between(
33513445
Returns
33523446
-------
33533447
Styler
3448+
Instance of class with range highlighted in given style.
33543449
33553450
See Also
33563451
--------
@@ -3471,6 +3566,7 @@ def highlight_quantile(
34713566
Returns
34723567
-------
34733568
Styler
3569+
Instance of class where values in quantile highlighted with given style.
34743570
34753571
See Also
34763572
--------
@@ -3576,6 +3672,11 @@ def from_custom_template(
35763672
Has the correct ``env``,``template_html``, ``template_html_table`` and
35773673
``template_html_style`` class attributes set.
35783674
3675+
See Also
3676+
--------
3677+
Styler.export : Export the styles applied to the current Styler.
3678+
Styler.use : Set the styles on the current Styler.
3679+
35793680
Examples
35803681
--------
35813682
>>> from pandas.io.formats.style import Styler

0 commit comments

Comments
 (0)