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

ENH: added an optional css id to <table> tags created by `frame.to_… #19594

Merged
merged 1 commit into from
Feb 9, 2018

Conversation

samghelms
Copy link
Contributor

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

@jreback
Copy link
Contributor

jreback commented Feb 8, 2018

pls just push to the same PR don’t open/close new ones for the same issue

@codecov
Copy link

codecov bot commented Feb 8, 2018

Codecov Report

Merging #19594 into master will decrease coverage by 0.02%.
The diff coverage is 100%.

Impacted file tree graph

@@            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
Flag Coverage Δ
#multiple 89.97% <100%> (-0.03%) ⬇️
#single 41.72% <16.66%> (-0.01%) ⬇️
Impacted Files Coverage Δ
pandas/core/frame.py 97.42% <ø> (ø) ⬆️
pandas/io/formats/format.py 96.25% <100%> (+0.01%) ⬆️
pandas/plotting/_converter.py 65.22% <0%> (-1.74%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b835127...a217db3. Read the comment docs.

Copy link
Contributor

@TomAugspurger TomAugspurger left a 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?

@@ -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)\
Copy link
Contributor

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


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)
Copy link
Contributor

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.

Copy link
Contributor Author

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

@@ -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`)
Copy link
Contributor

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 ...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks! Changed.

@jreback jreback added Enhancement Output-Formatting __repr__ of pandas objects, to_string IO HTML read_html, to_html, Styler.apply, Styler.applymap labels Feb 9, 2018
@jreback jreback added this to the 0.23.0 milestone Feb 9, 2018
@jreback jreback merged commit 7dcc864 into pandas-dev:master Feb 9, 2018
@jreback
Copy link
Contributor

jreback commented Feb 9, 2018

thanks @samghelms

@scls19fr
Copy link
Contributor

scls19fr commented Feb 9, 2018

Thanks @samghelms

harisbal pushed a commit to harisbal/pandas that referenced this pull request Feb 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement IO HTML read_html, to_html, Styler.apply, Styler.applymap Output-Formatting __repr__ of pandas objects, to_string
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add table id option to pandas.DataFrame.to_html
4 participants