@@ -1307,6 +1307,21 @@ def to_html(
13071307 See Also
13081308 --------
13091309 DataFrame.to_html: Write a DataFrame to a file, buffer or string in HTML format.
1310+
1311+ Examples
1312+ --------
1313+ >>> df = pd.DataFrame({'A': [1, 2], 'B': [3, 4]})
1314+ >>> print(df.style.to_html()) # doctest: +SKIP
1315+ <style type="text/css">
1316+ </style>
1317+ <table id="T_1e78e">
1318+ <thead>
1319+ <tr>
1320+ <th class="blank level0" > </th>
1321+ <th id="T_1e78e_level0_col0" class="col_heading level0 col0" >A</th>
1322+ <th id="T_1e78e_level0_col1" class="col_heading level0 col1" >B</th>
1323+ </tr>
1324+ ...
13101325 """
13111326 obj = self ._copy (deepcopy = True ) # manipulate table_styles on obj, not self
13121327
@@ -1419,6 +1434,12 @@ def to_string(
14191434 -------
14201435 str or None
14211436 If `buf` is None, returns the result as a string. Otherwise returns `None`.
1437+
1438+ Examples
1439+ --------
1440+ >>> df = pd.DataFrame({'A': [1, 2], 'B': [3, 4]})
1441+ >>> df.style.to_string()
1442+ ' A B\\ n0 1 3\\ n1 2 4\\ n'
14221443 """
14231444 obj = self ._copy (deepcopy = True )
14241445
@@ -1650,6 +1671,21 @@ def clear(self) -> None:
16501671 Reset the ``Styler``, removing any previously applied styles.
16511672
16521673 Returns None.
1674+
1675+ Examples
1676+ --------
1677+ >>> df = pd.DataFrame({'A': [1, 2], 'B': [3, np.nan]})
1678+
1679+ After any added style:
1680+
1681+ >>> df.style.highlight_null(color='yellow') # doctest: +SKIP
1682+
1683+ Remove it with:
1684+
1685+ >>> df.style.clear() # doctest: +SKIP
1686+
1687+ Please see:
1688+ `Table Visualization <../../user_guide/style.ipynb>`_ for more examples.
16531689 """
16541690 # create default GH 40675
16551691 clean_copy = Styler (self .data , uuid = self .uuid )
@@ -2257,6 +2293,22 @@ def set_uuid(self, uuid: str) -> Styler:
22572293 Almost all HTML elements within the table, and including the ``<table>`` element
22582294 are assigned ``id`` attributes. The format is ``T_uuid_<extra>`` where
22592295 ``<extra>`` is typically a more specific identifier, such as ``row1_col2``.
2296+
2297+ Examples
2298+ --------
2299+ >>> df = pd.DataFrame([[1, 2], [3, 4]], index=['A', 'B'], columns=['c1', 'c2'])
2300+
2301+ You can get the `id` attributes with the following:
2302+
2303+ >>> print((df).style.to_html()) # doctest: +SKIP
2304+
2305+ To add a title to column `c1`, its `id` is T_20a7d_level0_col0:
2306+
2307+ >>> df.style.set_uuid("T_20a7d_level0_col0")
2308+ ... .set_caption("Test") # doctest: +SKIP
2309+
2310+ Please see:
2311+ `Table visualization <../../user_guide/style.ipynb>`_ for more examples.
22602312 """
22612313 self .uuid = uuid
22622314 return self
@@ -2275,6 +2327,14 @@ def set_caption(self, caption: str | tuple | list) -> Styler:
22752327 Returns
22762328 -------
22772329 Styler
2330+
2331+ Examples
2332+ --------
2333+ >>> df = pd.DataFrame({'A': [1, 2], 'B': [3, 4]})
2334+ >>> df.style.set_caption("test") # doctest: +SKIP
2335+
2336+ Please see:
2337+ `Table Visualization <../../user_guide/style.ipynb>`_ for more examples.
22782338 """
22792339 msg = "`caption` must be either a string or 2-tuple of strings."
22802340 if isinstance (caption , (list , tuple )):
@@ -2323,6 +2383,14 @@ def set_sticky(
23232383 - `styler.set_sticky(axis="columns").hide(axis="columns")`
23242384
23252385 may produce strange behaviour due to CSS controls with missing elements.
2386+
2387+ Examples
2388+ --------
2389+ >>> df = pd.DataFrame({'A': [1, 2], 'B': [3, 4]})
2390+ >>> df.style.set_sticky(axis="index") # doctest: +SKIP
2391+
2392+ Please see:
2393+ `Table Visualization <../../user_guide/style.ipynb>`_ for more examples.
23262394 """
23272395 axis = self .data ._get_axis_number (axis )
23282396 obj = self .data .index if axis == 0 else self .data .columns
@@ -3073,6 +3141,11 @@ def bar( # pylint: disable=disallowed-name
30733141 This section of the user guide:
30743142 `Table Visualization <../../user_guide/style.ipynb>`_ gives
30753143 a number of examples for different settings and color coordination.
3144+
3145+ Examples
3146+ --------
3147+ >>> df = pd.DataFrame({'A': [1, 2, 3, 4], 'B': [3, 4, 5, 6]})
3148+ >>> df.style.bar(subset=['A'], color='gray') # doctest: +SKIP
30763149 """
30773150 if color is None and cmap is None :
30783151 color = "#d65f5f"
@@ -3147,6 +3220,14 @@ def highlight_null(
31473220 Styler.highlight_min: Highlight the minimum with a style.
31483221 Styler.highlight_between: Highlight a defined range with a style.
31493222 Styler.highlight_quantile: Highlight values defined by a quantile with a style.
3223+
3224+ Examples
3225+ --------
3226+ >>> df = pd.DataFrame({'A': [1, 2], 'B': [3, np.nan]})
3227+ >>> df.style.highlight_null(color='yellow') # doctest: +SKIP
3228+
3229+ Please see:
3230+ `Table Visualization <../../user_guide/style.ipynb>`_ for more examples.
31503231 """
31513232
31523233 def f (data : DataFrame , props : str ) -> np .ndarray :
@@ -3193,6 +3274,14 @@ def highlight_max(
31933274 Styler.highlight_min: Highlight the minimum with a style.
31943275 Styler.highlight_between: Highlight a defined range with a style.
31953276 Styler.highlight_quantile: Highlight values defined by a quantile with a style.
3277+
3278+ Examples
3279+ --------
3280+ >>> df = pd.DataFrame({'A': [2, 1], 'B': [3, 4]})
3281+ >>> df.style.highlight_max(color='yellow') # doctest: +SKIP
3282+
3283+ Please see:
3284+ `Table Visualization <../../user_guide/style.ipynb>`_ for more examples.
31963285 """
31973286
31983287 if props is None :
@@ -3241,6 +3330,14 @@ def highlight_min(
32413330 Styler.highlight_max: Highlight the maximum with a style.
32423331 Styler.highlight_between: Highlight a defined range with a style.
32433332 Styler.highlight_quantile: Highlight values defined by a quantile with a style.
3333+
3334+ Examples
3335+ --------
3336+ >>> df = pd.DataFrame({'A': [2, 1], 'B': [3, 4]})
3337+ >>> df.style.highlight_min(color='yellow') # doctest: +SKIP
3338+
3339+ Please see:
3340+ `Table Visualization <../../user_guide/style.ipynb>`_ for more examples.
32443341 """
32453342
32463343 if props is None :
0 commit comments