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

add functions to patch the _repr_html_ of pandas & polars dataframes #1108

Merged
merged 12 commits into from
Oct 17, 2024

Conversation

jeromedockes
Copy link
Member

@jeromedockes jeromedockes commented Oct 8, 2024

With

skrub.patch_display()

the default HTML representations of pandas & polars dataframes are replaced with TableReports

it can be undone with

skrub.unpatch_display()

patch_display can be called before or after importing the libraries (it will import them if they are installed but not imported yet. as this is only useful for interactive work I don't think it is a problem)

still need to add tests & an example but first I would like opinions on whether we actually want something like this or not

TODO:

  • changelog
  • tests
  • use in more examples?
  • mention in tablereport docstring
  • the drawback is it is slower than the default displays. Limit the number of columns for which we create plots?

Example

pandas : bool, optional (default=True)
If False, do not override the displays for pandas dataframes.
polars : bool, optional (default=True)
If False, do not override the displays for polars dataframes.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a "See also" to the TableReport (and reference this function as a see also in the docstring of the TableReport)

If False, do not restore the displays for pandas dataframes.
polars : bool, optional (default=True)
If False, do not restore the displays for polars dataframes.
"""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See also, also :)

@jeromedockes jeromedockes marked this pull request as ready for review October 16, 2024 13:50
@jeromedockes
Copy link
Member Author

ok this one is ready for review :)

@@ -18,6 +18,11 @@ Major changes
Minor changes
-------------

* The :func:`patch_display` function has been added. It changes the display of
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that this entry should not be under "minor change". Maybe a section "new features"?

@GaelVaroquaux GaelVaroquaux merged commit 4bbc6f1 into skrub-data:main Oct 17, 2024
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants