Skip to content

Commit 74fee2c

Browse files
author
Tom Augspurger
committed
Merge pull request pandas-dev#11766 from TomAugspurger/set-table-styles-doc
DOC: Explain `Styler.set_table_styles`
2 parents 925f62a + fe8cc13 commit 74fee2c

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

pandas/core/style.py

+15-1
Original file line numberDiff line numberDiff line change
@@ -520,17 +520,31 @@ def set_caption(self, caption):
520520

521521
def set_table_styles(self, table_styles):
522522
"""
523-
Set the table styles on a Styler
523+
Set the table styles on a Styler. These are placed in a
524+
``<style>`` tag before the generated HTML table.
524525
525526
.. versionadded:: 0.17.1
526527
527528
Parameters
528529
----------
529530
table_styles: list
531+
Each individual table_style should be a dictionary with
532+
``selector`` and ``props`` keys. ``selector`` should be a CSS
533+
selector that the style will be applied to (automatically
534+
prefixed by the table's UUID) and ``props`` should be a list of
535+
tuples with ``(attribute, value)``.
530536
531537
Returns
532538
-------
533539
self
540+
541+
Examples
542+
--------
543+
>>> df = pd.DataFrame(np.random.randn(10, 4))
544+
>>> df.style.set_table_styles(
545+
... [{'selector': 'tr:hover',
546+
... 'props': [('background-color', 'yellow')]}]
547+
... )
534548
"""
535549
self.table_styles = table_styles
536550
return self

0 commit comments

Comments
 (0)