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

Class Styler

pandas/io/formats/style.py:82–4127  ·  view source on GitHub ↗

r""" Helps style a DataFrame or Series according to the data with HTML and CSS. This class provides methods for styling and formatting a Pandas DataFrame or Series. The styled output can be rendered as HTML or LaTeX, and it supports CSS-based styling, allowing users to control color

Source from the content-addressed store, hash-verified

80
81
82class Styler(StylerRenderer):
83 r"""
84 Helps style a DataFrame or Series according to the data with HTML and CSS.
85
86 This class provides methods for styling and formatting a Pandas DataFrame or Series.
87 The styled output can be rendered as HTML or LaTeX, and it supports CSS-based
88 styling, allowing users to control colors, font styles, and other visual aspects of
89 tabular data. It is particularly useful for presenting DataFrame objects in a
90 Jupyter Notebook environment or when exporting styled tables for reports and
91
92 Parameters
93 ----------
94 data : Series or DataFrame
95 Data to be styled - either a Series or DataFrame.
96 precision : int, optional
97 Precision to round floats to. If not given defaults to
98 ``pandas.options.styler.format.precision``.
99 table_styles : list-like, default None
100 List of {selector: (attr, value)} dicts; see Notes.
101 uuid : str, default None
102 A unique identifier to avoid CSS collisions; generated automatically.
103 caption : str, tuple, default None
104 String caption to attach to the table. Tuple only used for LaTeX dual captions.
105 table_attributes : str, default None
106 Items that show up in the opening ``<table>`` tag
107 in addition to automatic (by default) id.
108 cell_ids : bool, default True
109 If True, each cell will have an ``id`` attribute in their HTML tag.
110 The ``id`` takes the form ``T_<uuid>_row<num_row>_col<num_col>``
111 where ``<uuid>`` is the unique identifier, ``<num_row>`` is the row
112 number and ``<num_col>`` is the column number.
113 na_rep : str, optional
114 Representation for missing values.
115 If ``na_rep`` is None, no special formatting is applied, and falls back to
116 ``pandas.options.styler.format.na_rep``.
117
118 uuid_len : int, default 5
119 If ``uuid`` is not specified, the length of the ``uuid`` to randomly generate
120 expressed in hex characters, in range [0, 32].
121 decimal : str, optional
122 Character used as decimal separator for floats, complex and integers. If not
123 given uses ``pandas.options.styler.format.decimal``.
124 thousands : str, optional, default None
125 Character used as thousands separator for floats, complex and integers. If not
126 given uses ``pandas.options.styler.format.thousands``.
127 escape : str, optional
128 Use 'html' to replace the characters ``&``, ``<``, ``>``, ``&#x27;``, and ``"``
129 in cell display string with HTML-safe sequences.
130
131 Use 'latex' to replace the characters ``&``, ``%``, ``$``, ``#``, ``_``,
132 ``{``, ``}``, ``~``, ``^``, and ``\`` in the cell display string with
133 LaTeX-safe sequences. Use 'latex-math' to replace the characters
134 the same way as in 'latex' mode, except for math substrings,
135 which either are surrounded by two characters ``$`` or start with
136 the character ``\(`` and end with ``\)``.
137 If not given uses ``pandas.options.styler.format.escape``.
138 formatter : str, callable, dict, optional
139 Object to define how values are displayed. See ``Styler.format``. If not given

Callers 15

styleMethod · 0.90
_to_latex_via_stylerMethod · 0.90
mi_stylerFunction · 0.90
stylerFunction · 0.90
test_clearFunction · 0.90
test_init_non_pandasMethod · 0.90
test_init_seriesMethod · 0.90
test_renderMethod · 0.90
test_multiple_renderMethod · 0.90
test_render_empty_dfsMethod · 0.90
test_render_doubleMethod · 0.90
test_init_with_na_repMethod · 0.90

Calls

no outgoing calls

Tested by 15

mi_stylerFunction · 0.72
stylerFunction · 0.72
test_clearFunction · 0.72
test_init_non_pandasMethod · 0.72
test_init_seriesMethod · 0.72
test_renderMethod · 0.72
test_multiple_renderMethod · 0.72
test_render_empty_dfsMethod · 0.72
test_render_doubleMethod · 0.72
test_init_with_na_repMethod · 0.72
test_captionMethod · 0.72
test_uuidMethod · 0.72