question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

DEPR: `LatexFormatter` in `DataFrame.to_latex` in favour of `Styler`

See original GitHub issue

The tracker of items needed to do before deprecating DataFrame.to_latex().

  • acceptance of the jinja2 requirement for LaTeX output, since Styler requires jinja2: this is blocker.
  • make Styler functional for all DataFrames (i.e. including non-unique columns, indexes) (#41269).
  • enhance for longtable keyword or other environments (#41866).
  • enhance for caption to allow short and long captions, and allow top/bottom caption placement. (#41659)
  • enhance with ability to style indexes/column headers with styles (e.g bold rows). (#41993)
  • enhance with an escape option for LaTeX characters. (#41619)
  • enhance .hide_columns with .show_columns alternative (optional) not necessary
  • enhance .hide_columns and .hide_index to have dual function to hide the entire array, or specific items (#41266)
  • make styler reactive to separate sparse columns and index separately (#41512)
  • acceptance of removal of specific kwargs and all formatting keyword args (see below).
  • validation for column_format to pass tests or just rely on docs/duck typing? not necessary
  • validation for caption to pass tests (#43368) or just remove the validation in favour of duck typing?
  • ability to format index with a formatter #43101
  • separate siunitx for encapsulating headers in curly braces only when necessary #43397
  • index names removal #43346
  • Optionally use multirow / multicol or just blank out cells. #43369 #43382
  • fix bug: label doesnt render if a caption is not given (table and longtable) #43399

Removed Keyword Args

col_space: removed since Styler.to_latex() does not necessarily produce display values of equal length, (this is a console display only arg) sparsify: replaced by alternative kwargs sparse_index and sparse_columns multicolumn, multicolumn_format, multirow: replaced by alternative kwargs multirow_align multicol_align formatters float_format : replaced by the superior df.style.format(...) args

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:1
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
jrebackcommented, May 25, 2021

we can straight depreciate DataFrame.to_latex w/o changing the implementation at all

sure if u can totally do everything in styler.to_latex that would be great but it’s likely not a big deal to implement things later / drop features if needed

1reaction
attack68commented, May 25, 2021

What about backward compatibility? If I understand correctly we would need to delegate DataFrame.to_latex to Styler.to_latex() and issue a FutureWarning. Should this be added to a checklist as well?

Don’t deprecations by definition warn of failing backwards compatibility in a future version? For 1.x is it enough to just warn that DataFrame methods will not be developed in future and will eventually be removed (or refactored), albeit they remain in place, as is, for those versions?

I’m trying hard to try and avoid the case where the existing keyword signature of DataFrame.to_html and DataFrame.to_latex must be maintained/replicated or squeezed into Stylers format, for the reason that some of them are bad arguments, and subjectively the new format is decoupled (more maintainable) and more flexible, and consistent from format to format (html, excel, latex).

Read more comments on GitHub >

github_iconTop Results From Across the Web

pandas.io.formats.style.Styler.to_latex
Convert simple cell-styles from CSS to LaTeX format. Any CSS not found in conversion table is dropped. A style can be forced by...
Read more >
Pandas DataFrame to Latex Formatter Functions
I am trying to export a DataFrame to Latex using a formatter function to specify the format of the columns. So far I...
Read more >
Pandas DataFrame to LaTeX table - LaTeX course - YouTube
I am going to show you how you can export a Pandas Data Frame to a LaTeX table. I will also show you...
Read more >
How to Style Pandas DataFrames Like a Pro
In Excel, you can leverage one-click coloring or conditional formatting to make your tables stand out. In Pandas, well, it's a bit trickier....
Read more >
Pandas Dataframe to Latex - Calmcode
Pandas to Latex logo ... print(df.head(10).to_latex(index=False)) ... If you've savvy with Latex, you can even expand the syntax by leveraging styles.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found