Skip to content

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

Merged
GaelVaroquaux merged 12 commits into
skrub-data:mainfrom
jeromedockes:patch-dataframes-repr-html
Oct 17, 2024
Merged

add functions to patch the _repr_html_ of pandas & polars dataframes#1108
GaelVaroquaux merged 12 commits into
skrub-data:mainfrom
jeromedockes:patch-dataframes-repr-html

Conversation

@jeromedockes
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Member Author

ok this one is ready for review :)

Comment thread CHANGES.rst
Minor changes
-------------

* The :func:`patch_display` function has been added. It changes the display of
Copy link
Copy Markdown
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
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