ENH: Styler.to_latex()
See original GitHub issueI have created a branch adding a to_latex
method to Styler
.
It is nowhere near readiness, and in particular:
- supports only cell background color as of now - adding some attributes should be trivial, adding others might be less so
- most importantly, it works on a copy of the dataframe casted
.astype(str)
, which is plain wrong because it discards features such as float formatting. For a good result, a better integration is needed with the code that currently does cell formatting inDataFrame.to_latex
.
This said, if anyone feels like experimenting, it might be slightly better than starting from scratch.
One aspect which I think is useful, even aside from this branch, and might benefit some discussion, is the pair of methods _latex_preserve
and _latex_restore
, which basically replace LaTeX commands so that they are not disturbed by escaping, and then restores them. There might be better way to code this, but I really think this is something we need to implement, and to offer to users who happen to nest LaTeX code in their cells.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:24
- Comments:67 (49 by maintainers)
Top Results From Across the Web
pandas.io.formats.style.Styler.to_latex
Write Styler to a file, buffer or string in LaTeX format. New in version 1.3.0. ... Defaults to 'l' for index and non-numeric...
Read more >pandas style options to latex - python - Stack Overflow
Pandas has two nice functionalities I use a lot - that's the df.style... option and the df.to_latex() call. But I do not know...
Read more >huxtable.pdf
Simple, modern interface to manipulate borders, size, position, captions, colours, text styles and number formatting. Table cells can span multiple rows and/or ...
Read more >Introduction-to-Pandas--slides.pdf - Forschungszentrum Jülich
Let's add names to ages; put everything into a dict(). In [14]: data = { ... It is recommended instead to use `DataFrame.style.to_latex....
Read more >Changelog • huxtable
A new brdr() class encapsulates border thickness, style and colour. ... Enhancement: when stars is NULL in huxreg , don't print a note...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Please, this isn’t helpful - see here for how to contribute, else wait for someone else to do it, but carrying on commenting
+1
is disruptiveFor that, I usually split the generated output into individual lines, insert the extra rules at pre-defined locations and concatenate the result. This breaks easily but it is better than nothing.