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.

CLN/API: implemented to_html in terms of .style

See original GitHub issue

Implement to_html / notebook repr based on .style.

prob need to expand this to take a use argument (to select the style, needs to be ‘classic’ for a while, to replicate the current .to_html one).

Issue Analytics

  • State:open
  • Created 8 years ago
  • Comments:17 (17 by maintainers)

github_iconTop GitHub Comments

1reaction
attack68commented, Mar 11, 2021

You’re right if it is certain that HTMLFormatter can be completely removed. Is that the case? It seems not, guessing from @toobaz’ comment.

@moi90 If the goal is to replicate all of the functionality from DataFrame.to_html() then yes it can be done and a lot has already been done in my wip pr. Not all though, because I wanted to raise the issue about simply blindly replicating a function which in some cases produces deprecated HTML, and instead consider the merits of making some changes perhaps with a view to pandas 2.0.

While your attempt in master…attack68:latex_styler_mvp is cool, I suspect the complexity will increase quite a bit once we start supporting formatting (which won’t use stuff like css), to the point that what jinja2 actually delivers is only a small part of the task of formatting to LaTeX.

@toobaz I progressed the MVP to state where it now has a lot of general conditional styling capability for latex tables. See my response here I still want to be able to add some table level styles like column colouring or odd/even colouring but these are quite easy extensions.

I would be happy to be proven wrong though. How difficult would it be, in #40312, to run the test suite with DataFrame.to_html() replaced with the jinja2 implementation, just to see what breaks?

Quite easy, just need to redirect the method, when I push it I will ping you to take a look at test results.

0reactions
attack68commented, Jan 26, 2022

In #45382 I’m proposing changing the signature of DataFrame.to_latex to:

DataFrame.to_latex(hide, format, format_index, render_kwargs)

and this will perform the following:

DataFrame.style.hide(**hide).format(**format).format_index(**format_index).to_latex(**render_kwargs)

This has the advantage of:

  • converting the method to use Styler implementation
  • not require updates to the arguments signature of DataFrame.to_latex since it passes the kwargs through
  • allows a structured deprecation cycle where all the existing args can be restructured into this format as documented.

Is this reasonable and would it be appropriate to aim for something similar with to_html for v2.0?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Making Use of APIs in Your Front End | by Patrick Pierre
So in this post, I am going to help you learn more about APIs and how you can use them through a simple...
Read more >
Introduction to web APIs - Learn web development | MDN
Common browser APIs​​ APIs for manipulating documents loaded into the browser. The most obvious example is the DOM (Document Object Model) API, ...
Read more >
Best practices for REST API design - Stack Overflow Blog
In this article, we'll look at how to design REST APIs to be easy to understand for anyone consuming them, future-proof, and secure...
Read more >
HTML APIs: What They Are And How To Design A Good One
HTML APIs improve collaboration between designers and developers, lift some work from the shoulders of the latter, and enable designers to ...
Read more >
The anatomy of an API call | The Uptrends Blog
A simple example is an application that takes in zip codes and returns city and state information. The API client (the user) asks...
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