Skip to content

Commit 3bba8b2

Browse files
attack68TLouf
authored andcommitted
DOC: add Styler.to_latex info in io.rst doc page (pandas-dev#41658)
1 parent cf11c16 commit 3bba8b2

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

doc/source/user_guide/io.rst

+36
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ The pandas I/O API is a set of top level ``reader`` functions accessed like
2222
text;Fixed-Width Text File;:ref:`read_fwf<io.fwf_reader>`
2323
text;`JSON <https://www.json.org/>`__;:ref:`read_json<io.json_reader>`;:ref:`to_json<io.json_writer>`
2424
text;`HTML <https://en.wikipedia.org/wiki/HTML>`__;:ref:`read_html<io.read_html>`;:ref:`to_html<io.html>`
25+
text;`LaTeX <https://en.wikipedia.org/wiki/LaTeX>`__;;:ref:`Styler.to_latex<io.latex>`
2526
text;`XML <https://www.w3.org/standards/xml/core>`__;:ref:`read_xml<io.read_xml>`;:ref:`to_xml<io.xml>`
2627
text; Local clipboard;:ref:`read_clipboard<io.clipboard>`;:ref:`to_clipboard<io.clipboard>`
2728
binary;`MS Excel <https://en.wikipedia.org/wiki/Microsoft_Excel>`__;:ref:`read_excel<io.excel_reader>`;:ref:`to_excel<io.excel_writer>`
@@ -2830,7 +2831,42 @@ parse HTML tables in the top-level pandas io function ``read_html``.
28302831
.. |lxml| replace:: **lxml**
28312832
.. _lxml: https://lxml.de
28322833

2834+
.. _io.latex:
28332835

2836+
LaTeX
2837+
-----
2838+
2839+
.. versionadded:: 1.3.0
2840+
2841+
Currently there are no methods to read from LaTeX, only output methods.
2842+
2843+
Writing to LaTeX files
2844+
''''''''''''''''''''''
2845+
2846+
.. note::
2847+
2848+
DataFrame *and* Styler objects currently have a ``to_latex`` method. We recommend
2849+
using the `Styler.to_latex() <../reference/api/pandas.io.formats.style.Styler.to_latex.rst>`__ method
2850+
over `DataFrame.to_latex() <../reference/api/pandas.DataFrame.to_latex.rst>`__ due to the former's greater flexibility with
2851+
conditional styling, and the latter's possible future deprecation.
2852+
2853+
Review the documentation for `Styler.to_latex <../reference/api/pandas.io.formats.style.Styler.to_latex.rst>`__,
2854+
which gives examples of conditional styling and explains the operation of its keyword
2855+
arguments.
2856+
2857+
For simple application the following pattern is sufficient.
2858+
2859+
.. ipython:: python
2860+
2861+
df = pd.DataFrame([[1, 2], [3, 4]], index=["a", "b"], columns=["c", "d"])
2862+
print(df.style.to_latex())
2863+
2864+
To format values before output, chain the `Styler.format <../reference/api/pandas.io.formats.style.Styler.format.rst>`__
2865+
method.
2866+
2867+
.. ipython:: python
2868+
2869+
print(df.style.format("{}").to_latex())
28342870
28352871
XML
28362872
---

0 commit comments

Comments
 (0)