Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: REF: DataFrame.to_html directs to Styler.to_html #43161

Closed
wants to merge 4 commits into from

Conversation

attack68
Copy link
Contributor

This is being worked towards in #41693. Please look at that issue and comment if there are specific features we need to keep/discuss. This is a medium term project I've been working on but would be great if someone else in team can be sounding board.

@alimcmaster1
Copy link
Member

Seems like some great work is being done here. I'm likely missing something but has anyone else in @pandas-dev/pandas-core approved/+1 this?

As I suspect this might receive some complaints from users for 1.4 since this is such a commonly used method.

@alimcmaster1 alimcmaster1 added this to the 1.4 milestone Aug 25, 2021
@alimcmaster1 alimcmaster1 added the Deprecate Functionality to remove in pandas label Aug 25, 2021
@bashtage
Copy link
Contributor

What goal does it serve to have users reach deeper to access a method that has been around for ages?

@jreback
Copy link
Contributor

jreback commented Aug 25, 2021

we could leave this method snd just return the styler inpl of it? (and if there are specific deprecations then do those for unsupported features?)

@jorisvandenbossche
Copy link
Member

jorisvandenbossche commented Aug 25, 2021

@attack68 I seem to remember some previous discussion about this, but it's not in the issue you link (#41693). Do you know of older issues that had some of this? (#41693 does summarize some concerns that I suppose came from earlier discussions)

(eg issues like having jinja2 as a requirement for html repr in the notebook, which basically makes jinja2 a semi-required dependency)

EDIT: one such issue might be #11700

@attack68
Copy link
Contributor Author

What goal does it serve to have users reach deeper to access a method that has been around for ages?

  • maintaining only one set of rendering methods and tests to produce HTML output.
  • removing some of the deprecated features of DataFrame.to_html that haven't been followed up over the years.
  • better performance and more features in Styler.to_html.

@attack68 I seem to remember some previous discussion about this, but it's not in the issue you link (#41693). Do you know of older issues that had some of this? (#41693 does summarize some concerns that I suppose came from earlier discussions) actually #11700

Yes @jorisvandenbossche, in that issue you mentioned two barriers, which have been addressed. You identified same advantages as me, and mentioned disadvantages; the performance is resolved, you can test but I think Styler.to_html(exclude_styles=True) is faster than DataFrame.to_html(), and the jinja2 dependency is a must if this is to progress.

we could leave this method snd just return the styler inpl of it? (and if there are specific deprecations then do those for unsupported features?)

@jreback yes for sure, but as mentioned would need a refactoring of the input arguments, I think.

@jreback
Copy link
Contributor

jreback commented Aug 25, 2021

so i think would be ok to deprecate these scenarios

  • no jinja2
  • whatever features / kwargs that are not supported ultimately

then we can remove the existing implementation in the future (though keep .to_html is prob ok and just have it call the styler inpl)

@attack68 attack68 changed the title WIP: DEPR: DataFrame.to_html in favour of Styler.to_html WIP: REF: DataFrame.to_html directs to Styler.to_html Aug 28, 2021
@bashtage
Copy link
Contributor

What goal does it serve to have users reach deeper to access a method that has been around for ages?

  • maintaining only one set of rendering methods and tests to produce HTML output.
  • removing some of the deprecated features of DataFrame.to_html that haven't been followed up over the years.
  • better performance and more features in Styler.to_html.

I wan't suggesting keeping 2 implementation. I was just quibbling moving to_html to a different location. I think what @jreback said is the best way forward.

@attack68
Copy link
Contributor Author

I wan't suggesting keeping 2 implementation. I was just quibbling moving to_html to a different location. I think what @jreback said is the best way forward.

will work towards that, seems sensible and has good support.

@jorisvandenbossche
Copy link
Member

However, I think we need to discuss the jinja2 dependency a bit more, first. What does that mean? Do we keep that as an optional dependency as it is right now?
In practice, that would mean that we don't support the html rendering in notebooks by default. IMO, that would be a bad usability regression. One option to solve this is to make jinja2 a required, hard dependency of pandas. But I don't know if that is what others where also thinking.

@attack68
Copy link
Contributor Author

attack68 commented Aug 31, 2021

Personally, I expected that jinja2 would be added as a hard requirement.

Having said that using pandas in a Notebook is commonly used with charting, where matplotlib is an optional dependency, so forcing another optional dependency might not be too restrictive, especially if well documented.

A fallback for a non-jinja2 notebook could be to use the string representation of a DataFrame with/without a warning (although currently it doesnt seem to trim for large dfs)?

@jreback
Copy link
Contributor

jreback commented Sep 1, 2021

so adding jinja2 as a hard requirement for styler is fine i think

@jreback
Copy link
Contributor

jreback commented Sep 1, 2021

ahh just read @jorisvandenbossche comment again

i think we should just add it as a hard requirement

@lithomas1
Copy link
Member

Quick question: Would this be targeted for 1.4 or 2.0? I feel like we would need a deprecation cycle before switching the implementations around.

@github-actions
Copy link
Contributor

github-actions bot commented Oct 9, 2021

This pull request is stale because it has been open for thirty days with no activity. Please update or respond to this comment if you're still interested in working on this.

@github-actions github-actions bot added the Stale label Oct 9, 2021
@attack68
Copy link
Contributor Author

closing this temporarily in favour of #44451

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Deprecate Functionality to remove in pandas Stale
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants