MCPcopy
hub / github.com/pandas-dev/pandas / set_table_styles

Method set_table_styles

pandas/io/formats/style.py:2717–2859  ·  view source on GitHub ↗

Set the table styles included within the `` `` HTML element. This function can be used to style the entire table, columns, rows or specific HTML selectors. Parameters ---------- table_styles : list or dict If supplying a list, each

(
        self,
        table_styles: dict[Any, CSSStyles] | CSSStyles | None = None,
        axis: AxisInt = 0,
        overwrite: bool = True,
        css_class_names: dict[str, str] | None = None,
    )

Source from the content-addressed store, hash-verified

2715 return self.set_table_styles(styles, overwrite=False)
2716
2717 def set_table_styles(
2718 self,
2719 table_styles: dict[Any, CSSStyles] | CSSStyles | None = None,
2720 axis: AxisInt = 0,
2721 overwrite: bool = True,
2722 css_class_names: dict[str, str] | None = None,
2723 ) -> Styler:
2724 """
2725 Set the table styles included within the ``<style>`` HTML element.
2726
2727 This function can be used to style the entire table, columns, rows or
2728 specific HTML selectors.
2729
2730 Parameters
2731 ----------
2732 table_styles : list or dict
2733 If supplying a list, each individual table_style should be a
2734 dictionary with ``selector`` and ``props`` keys. ``selector``
2735 should be a CSS selector that the style will be applied to
2736 (automatically prefixed by the table&#x27;s UUID) and ``props``
2737 should be a list of tuples with ``(attribute, value)``.
2738 If supplying a dict, the dict keys should correspond to
2739 column names or index values, depending upon the specified
2740 `axis` argument. These will be mapped to row or col CSS
2741 selectors. MultiIndex values as dict keys should be
2742 in their respective tuple form. The dict values should be
2743 a list as specified in the form with CSS selectors and
2744 props that will be applied to the specified row or column.
2745 axis : {0 or 'index', 1 or 'columns', None}, default 0
2746 Apply to each column (``axis=0`` or ``'index'``), to each row
2747 (``axis=1`` or ``'columns'``). Only used if `table_styles` is
2748 dict.
2749 overwrite : bool, default True
2750 Styles are replaced if `True`, or extended if `False`. CSS
2751 rules are preserved so most recent styles set will dominate
2752 if selectors intersect.
2753 css_class_names : dict, optional
2754 A dict of strings used to replace the default CSS classes described below.
2755
2756 Returns
2757 -------
2758 Styler
2759 Instance of class with specified table styles set.
2760
2761 See Also
2762 --------
2763 Styler.set_td_classes: Set the DataFrame of strings added to the ``class``
2764 attribute of ``<td>`` HTML elements.
2765 Styler.set_table_attributes: Set the table attributes added to the ``<table>``
2766 HTML element.
2767
2768 Notes
2769 -----
2770 The default CSS classes dict, whose values can be replaced is as follows:
2771
2772 .. code-block:: python
2773
2774 css_class_names = {

Callers 15

useMethod · 0.95
set_stickyMethod · 0.95
test_table_stylesMethod · 0.95
to_latexMethod · 0.80
to_htmlMethod · 0.80
mi_styler_compFunction · 0.80

Calls 5

format_table_stylesFunction · 0.90
_get_axis_numberMethod · 0.80
get_indexer_forMethod · 0.80
itemsMethod · 0.45