Skip to content

Re-unify execution paths for to_html() and _repr_html_() #30727

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

Open
greglandrum opened this issue Jan 6, 2020 · 0 comments
Open

Re-unify execution paths for to_html() and _repr_html_() #30727

greglandrum opened this issue Jan 6, 2020 · 0 comments
Labels
IO HTML read_html, to_html, Styler.apply, Styler.applymap Refactor Internal refactoring of code

Comments

@greglandrum
Copy link

The changes associated with #27991 (merged as part of v0.25.1) changed the behavior of DataFrame._repr_html_()

We use monkey patching to allow the automatic display (within Jupyter notebooks) of chemical structures stored in DataFrames as part of the RDKit project. Given how useful it is to be able to automatically render specialized data types in DataFrames, I would assume we're not the only ones doing this. For those who are interested, here's an example from the RDKit community demonstrating what this looks like - https://www.blopig.com/blog/2017/02/using-rdkit-to-load-ligand-sdfs-into-pandas-dataframes/

Previous to v0.25.1 we could simply monkey patch DataFrame.to_html() since it was called by DataFrame._repr_html_(), but now it looks like we need to patch both methods. Doing this kind of patching is always a bit fraught and having to do it twice really seems to be begging for support problems down the road. Note: A single patch to DataFrameFormatter.to_html() would also be possible, but it looks like that would make it impossible to for us to disable the specialized rendering on a DataFrame by DataFrame basis.

I'm happy to submit a PR with a fix if the maintainers agree that re-unifying these two is desirable.

I think this should probably be classified as a Cleanup item, but I didn't want to presume.

@jbrockmendel jbrockmendel added the Refactor Internal refactoring of code label Feb 25, 2020
@mroeschke mroeschke added the IO HTML read_html, to_html, Styler.apply, Styler.applymap label Jul 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
IO HTML read_html, to_html, Styler.apply, Styler.applymap Refactor Internal refactoring of code
Projects
None yet
Development

No branches or pull requests

3 participants