From 052ec9817dde470b7b1ff4f06c6be68306ae0717 Mon Sep 17 00:00:00 2001 From: "JHM Darbyshire (iMac)" Date: Sun, 16 Jan 2022 18:02:54 +0100 Subject: [PATCH 1/3] doc string replacement --- pandas/io/formats/style.py | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/pandas/io/formats/style.py b/pandas/io/formats/style.py index 87d4bbcc38373..830b06e9d0641 100644 --- a/pandas/io/formats/style.py +++ b/pandas/io/formats/style.py @@ -97,6 +97,15 @@ def _mpl(func: Callable): color = """color : str, default 'yellow' Background color to use for highlighting.""" +buf = """buf : str, path object, file-like object, optional + String, path object (implementing ``os.PathLike[str]``), or file-like + object implementing a string ``write()`` function. If `None`, the result is + returned as a string.""" + +encoding = """encoding : str, optional + Character encoding setting for file output (and meta tags if available). + Defaults to ``pandas.options.styler.render.encoding`` value of "utf-8".""" + # ### @@ -485,6 +494,7 @@ def to_excel( engine=engine, ) + @Substitution(buf=buf, encoding=encoding) def to_latex( self, buf: FilePath | WriteBuffer[str] | None = None, @@ -512,10 +522,7 @@ def to_latex( Parameters ---------- - buf : str, path object, file-like object, or None, default None - String, path object (implementing ``os.PathLike[str]``), or file-like - object implementing a string ``write()`` function. If None, the result is - returned as a string. + %(buf)s column_format : str, optional The LaTeX column specification placed in location: @@ -600,9 +607,7 @@ def to_latex( ``pandas.options.styler.latex.environment``, which is `None`. .. versionadded:: 1.4.0 - encoding : str, optional - Character encoding setting. Defaults - to ``pandas.options.styler.render.encoding``, which is "utf-8". + %(encoding)s convert_css : bool, default False Convert simple cell-styles from CSS to LaTeX format. Any CSS not found in conversion table is dropped. A style can be forced by adding option @@ -1053,6 +1058,7 @@ def to_latex( latex, buf=buf, encoding=None if buf is None else encoding ) + @Substitution(buf=buf, encoding=encoding) def to_html( self, buf: FilePath | WriteBuffer[str] | None = None, @@ -1077,10 +1083,7 @@ def to_html( Parameters ---------- - buf : str, path object, file-like object, or None, default None - String, path object (implementing ``os.PathLike[str]``), or file-like - object implementing a string ``write()`` function. If None, the result is - returned as a string. + %(buf)s table_uuid : str, optional Id attribute assigned to the HTML element in the format: @@ -1127,9 +1130,7 @@ def to_html( which is 262144 (18 bit browser rendering). .. versionadded:: 1.4.0 - encoding : str, optional - Character encoding setting for file output, and HTML meta tags. - Defaults to ``pandas.options.styler.render.encoding`` value of "utf-8". + %(encoding)s doctype_html : bool, default False Whether to output a fully structured HTML file including all HTML elements, or just the core ``