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

Method format

pandas/io/formats/style_render.py:978–1233  ·  view source on GitHub ↗

r""" Format the text display value of cells. Parameters ---------- formatter : str, callable, dict or None Object to define how values are displayed. See notes. subset : label, array-like, IndexSlice, optional A valid 2d input to `Data

(
        self,
        formatter: ExtFormatter | None = None,
        subset: Subset | None = None,
        na_rep: str | None = None,
        precision: int | None = None,
        decimal: str = ".",
        thousands: str | None = None,
        escape: str | None = None,
        hyperlinks: str | None = None,
    )

Source from the content-addressed store, hash-verified

976 )
977
978 def format(
979 self,
980 formatter: ExtFormatter | None = None,
981 subset: Subset | None = None,
982 na_rep: str | None = None,
983 precision: int | None = None,
984 decimal: str = ".",
985 thousands: str | None = None,
986 escape: str | None = None,
987 hyperlinks: str | None = None,
988 ) -> StylerRenderer:
989 r"""
990 Format the text display value of cells.
991
992 Parameters
993 ----------
994 formatter : str, callable, dict or None
995 Object to define how values are displayed. See notes.
996 subset : label, array-like, IndexSlice, optional
997 A valid 2d input to `DataFrame.loc[<subset>]`, or, in the case of a 1d input
998 or single key, to `DataFrame.loc[:, <subset>]` where the columns are
999 prioritised, to limit ``data`` to *before* applying the function.
1000 na_rep : str, optional
1001 Representation for missing values.
1002 If ``na_rep`` is None, no special formatting is applied.
1003 precision : int, optional
1004 Floating point precision to use for display purposes, if not determined by
1005 the specified ``formatter``.
1006 decimal : str, default "."
1007 Character used as decimal separator for floats, complex and integers.
1008 thousands : str, optional, default None
1009 Character used as thousands separator for floats, complex and integers.
1010 escape : str, optional
1011 Use 'html' to replace the characters ``&``, ``<``, ``>``, ``&#x27;``, and ``"``
1012 in cell display string with HTML-safe sequences.
1013 Use 'latex' to replace the characters ``&``, ``%``, ``$``, ``#``, ``_``,
1014 ``{``, ``}``, ``~``, ``^``, and ``\`` in the cell display string with
1015 LaTeX-safe sequences.
1016 Use 'latex-math' to replace the characters the same way as in 'latex' mode,
1017 except for math substrings, which either are surrounded
1018 by two characters ``$`` or start with the character ``\(`` and
1019 end with ``\)``. Escaping is done before ``formatter``.
1020 hyperlinks : {"html", "latex"}, optional
1021 Convert string patterns containing https://, http://, ftp:// or www. to
1022 HTML <a> tags as clickable URL hyperlinks if "html", or LaTeX \href
1023 commands if "latex".
1024
1025 Returns
1026 -------
1027 Styler
1028 Returns itself for chaining.
1029
1030 See Also
1031 --------
1032 Styler.format_index: Format the text display value of index labels.
1033
1034 Notes
1035 -----

Callers 15

process_axesMethod · 0.45
read_coordinatesMethod · 0.45
selectMethod · 0.45
select_coordsMethod · 0.45
_cast_to_stata_typesFunction · 0.45
_prepare_value_labelsMethod · 0.45
_read_new_headerMethod · 0.45
_read_old_headerMethod · 0.45
_check_column_namesMethod · 0.45
__init__Method · 0.45
_applyMethod · 0.45

Calls 5

non_reducing_sliceFunction · 0.85
_maybe_wrap_formatterFunction · 0.85
clearMethod · 0.80
get_indexer_forMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected