-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
ENH: added an optional css id to <table>
tags created by `frame.to_…
#19594
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
Conversation
pls just push to the same PR don’t open/close new ones for the same issue |
Codecov Report
@@ Coverage Diff @@
## master #19594 +/- ##
==========================================
- Coverage 91.62% 91.59% -0.03%
==========================================
Files 150 150
Lines 48790 48795 +5
==========================================
- Hits 44703 44696 -7
- Misses 4087 4099 +12
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add a release note for 0.23.0 under enhancements?
pandas/io/formats/format.py
Outdated
@@ -1220,8 +1228,11 @@ def write_result(self, buf): | |||
self.write('<div{style}>'.format(style=div_style)) | |||
|
|||
self.write_style() | |||
self.write('<table border="{border}" class="{cls}">' | |||
.format(border=self.border, cls=' '.join(_classes)), indent) | |||
id_section = ' id="{table_id}"'.format(table_id=self.table_id)\ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: Parenthesis instead of a backslash
pandas/core/frame.py
Outdated
|
||
return self.to_html(max_rows=max_rows, max_cols=max_cols, | ||
show_dimensions=show_dimensions, notebook=True) | ||
show_dimensions=show_dimensions, notebook=True, | ||
table_id=unique_id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the benefit of having a random table_id for tables in the notebook? I'd prefer to not have them unless there's a compelling reason.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My thought was that it can't hurt since the id is almost certain not to conflict with another and it might make it easier for people to apply custom styles/javascript to their notebook. Because the id is random, however, I can see how this might be hard and I will get rid of the feature (for now) (more pull requests to come :) ). Updated in the most recent pull request
doc/source/whatsnew/v0.23.0.txt
Outdated
@@ -690,6 +690,7 @@ I/O | |||
^^^ | |||
|
|||
- :func:`read_html` now rewinds seekable IO objects after parse failure, before attempting to parse with a new parser. If a parser errors and the object is non-seekable, an informative error is raised suggesting the use of a different parser (:issue:`17975`) | |||
- :func:`read_html` now has an option to add an id to the leading `<table>` tag (:issue:`8496`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to_html
, not read. Also it's a method, so
:meth:`DataFrame.to_html` now has ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Changed.
thanks @samghelms |
Thanks @samghelms |
This is useful for the reasons mentioned in #8496
Automatically create a random id for tables created using
_repr_html_
using uuid.Also updated
test_repr_html_float
to be more descriptive and avoid conflicts with random numbers in the id for_repr_html_
closes Add table id option to pandas.DataFrame.to_html #8496
tests added / passed
passes
git diff upstream/master -u -- "*.py" | flake8 --diff
whatsnew entry