Skip to content

Commit b46dd7f

Browse files
attack68mroeschke
authored andcommitted
REF: Use Styler implementation for DataFrame.to_latex (pandas-dev#47970)
* Base implementation * Base implementation * test fix up * test fix up * test fix up * doc change * doc change * doc change * mypy fixes * ivanov doc comment * ivanov doc comment * rhshadrach reduction * change text from 1.5.0 to 2.0.0 * remove argument col_space and add whatsnew * mroeschke requests * mroeschke requests * pylint fix * Whats new text improvements and description added * Update doc/source/whatsnew/v2.0.0.rst Co-authored-by: Matthew Roeschke <[email protected]> * Update doc/source/whatsnew/v2.0.0.rst * remove trailing whitespace * remove trailing whitespace * Whats new linting fixes * mroeschke requests Co-authored-by: JHM Darbyshire (iMac) <[email protected]> Co-authored-by: Matthew Roeschke <[email protected]>
1 parent 3f5870b commit b46dd7f

File tree

10 files changed

+534
-383
lines changed

10 files changed

+534
-383
lines changed

doc/source/whatsnew/v2.0.0.rst

+33
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,37 @@ Now, the axes return an empty :class:`RangeIndex`.
454454
pd.Series().index
455455
pd.DataFrame().axes
456456
457+
.. _whatsnew_200.api_breaking.to_latex:
458+
459+
DataFrame to LaTeX has a new render engine
460+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
461+
462+
The existing :meth:`DataFrame.to_latex` has been restructured to utilise the
463+
extended implementation previously available under :meth:`.Styler.to_latex`.
464+
The arguments signature is similar, albeit ``col_space`` has been removed since
465+
it is ignored by LaTeX engines. This render engine also requires ``jinja2`` as a
466+
dependency which needs to be installed, since rendering is based upon jinja2 templates.
467+
468+
The pandas options below are no longer used and will be removed in future releases.
469+
The alternative options giving similar functionality are indicated below:
470+
471+
- ``display.latex.escape``: replaced with ``styler.format.escape``,
472+
- ``display.latex.longtable``: replaced with ``styler.latex.environment``,
473+
- ``display.latex.multicolumn``, ``display.latex.multicolumn_format`` and
474+
``display.latex.multirow``: replaced with ``styler.sparse.rows``,
475+
``styler.sparse.columns``, ``styler.latex.multirow_align`` and
476+
``styler.latex.multicol_align``,
477+
- ``display.latex.repr``: replaced with ``styler.render.repr``,
478+
- ``display.max_rows`` and ``display.max_columns``: replace with
479+
``styler.render.max_rows``, ``styler.render.max_columns`` and
480+
``styler.render.max_elements``.
481+
482+
Note that the behaviour of ``_repr_latex_`` is also changed. Previously
483+
setting ``display.latex.repr`` would generate LaTeX only when using nbconvert for a
484+
JupyterNotebook, and not when the user is running the notebook. Now the
485+
``styler.render.repr`` option allows control of the specific output
486+
within JupyterNotebooks for operations (not just on nbconvert). See :issue:`39911`.
487+
457488
.. _whatsnew_200.api_breaking.deps:
458489

459490
Increased minimum versions for dependencies
@@ -619,6 +650,7 @@ Removal of prior version deprecations/changes
619650
- Removed deprecated :meth:`.Styler.set_na_rep` and :meth:`.Styler.set_precision` (:issue:`49397`)
620651
- Removed deprecated :meth:`.Styler.where` (:issue:`49397`)
621652
- Removed deprecated :meth:`.Styler.render` (:issue:`49397`)
653+
- Removed deprecated argument ``col_space`` in :meth:`DataFrame.to_latex` (:issue:`47970`)
622654
- Removed deprecated argument ``null_color`` in :meth:`.Styler.highlight_null` (:issue:`49397`)
623655
- Removed deprecated argument ``check_less_precise`` in :meth:`.testing.assert_frame_equal`, :meth:`.testing.assert_extension_array_equal`, :meth:`.testing.assert_series_equal`, :meth:`.testing.assert_index_equal` (:issue:`30562`)
624656
- Removed deprecated ``null_counts`` argument in :meth:`DataFrame.info`. Use ``show_counts`` instead (:issue:`37999`)
@@ -793,6 +825,7 @@ Removal of prior version deprecations/changes
793825
- Changed behavior of comparison of ``NaT`` with a ``datetime.date`` object; these now raise on inequality comparisons (:issue:`39196`)
794826
- Enforced deprecation of silently dropping columns that raised a ``TypeError`` in :class:`Series.transform` and :class:`DataFrame.transform` when used with a list or dictionary (:issue:`43740`)
795827
- Changed behavior of :meth:`DataFrame.apply` with list-like so that any partial failure will raise an error (:issue:`43740`)
828+
- Changed behaviour of :meth:`DataFrame.to_latex` to now use the Styler implementation via :meth:`.Styler.to_latex` (:issue:`47970`)
796829
- Changed behavior of :meth:`Series.__setitem__` with an integer key and a :class:`Float64Index` when the key is not present in the index; previously we treated the key as positional (behaving like ``series.iloc[key] = val``), now we treat it is a label (behaving like ``series.loc[key] = val``), consistent with :meth:`Series.__getitem__`` behavior (:issue:`33469`)
797830
- Removed ``na_sentinel`` argument from :func:`factorize`, :meth:`.Index.factorize`, and :meth:`.ExtensionArray.factorize` (:issue:`47157`)
798831
- Changed behavior of :meth:`Series.diff` and :meth:`DataFrame.diff` with :class:`ExtensionDtype` dtypes whose arrays do not implement ``diff``, these now raise ``TypeError`` rather than casting to numpy (:issue:`31025`)

0 commit comments

Comments
 (0)