Skip to content

ENH: add parameter to to_html for HTML border #14061

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

Merged
merged 1 commit into from
Aug 31, 2016

Conversation

TomAugspurger
Copy link
Contributor

@TomAugspurger TomAugspurger commented Aug 22, 2016

Closes #11563

Previously this was hardcoded to <table border="1" ...>. Now we allow an option to to_html.

The only controversial bit here may be the option. I really don't like having options control output, but given that this is essentially a repr I think it's OK. It's also the only way to expose it to the user since _repr_html_ can't take any arguments. I also selfishly need this for my own library, where the user wouldn't be able to pass an option 😄

Interestingly, the border="0" is seemingly redundant in the notebook:

screen shot 2016-08-21 at 7 51 02 pm

Looking at the CSS, I see jupyter applying a border-width of 0.909091px in their style, though I can't remember if I've adjusted the default CSS on this computer; will check later.

@TomAugspurger TomAugspurger added Output-Formatting __repr__ of pandas objects, to_string IO HTML read_html, to_html, Styler.apply, Styler.applymap labels Aug 22, 2016
@TomAugspurger TomAugspurger added this to the 0.19.0 milestone Aug 22, 2016
@TomAugspurger TomAugspurger changed the title ENH: add parameter for HTML border ENH: add parameter to to_html for HTML border Aug 22, 2016
@codecov-io
Copy link

codecov-io commented Aug 22, 2016

Current coverage is 85.27% (diff: 100%)

Merging #14061 into master will increase coverage by <.01%

@@             master     #14061   diff @@
==========================================
  Files           139        139          
  Lines         50511      50517     +6   
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
+ Hits          43071      43078     +7   
+ Misses         7440       7439     -1   
  Partials          0          0          

Powered by Codecov. Last update 10bf721...49e57e7

notebook : {True, False}, optional, default False
Whether the generated HTML is for IPython Notebook.
border : int
A ``border=border`` tag is included in the opening ``<table>`` tag.
Copy link
Member

Choose a reason for hiding this comment

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

I'm not really up to date on HTML nomenclature, but I think border is probably an attribute rather than a tag?

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, fixed (and in core/frame.py too)

@@ -371,6 +371,9 @@ display.multi_sparse True "Sparsify" MultiIndex display (don't
display.notebook_repr_html True When True, IPython notebook will
use html representation for
pandas objects (if it is available).
display.html_border 1 A ``border=value`` attribute is
Copy link
Contributor

Choose a reason for hiding this comment

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

I would namespace this html, as prob add more as time goes on.

Further would deprecate notebook_repr_html and rename to html.notebook (or maybe notebook.html=True) (and not in the .display space to differentiate)

@jorisvandenbossche jorisvandenbossche merged commit 47a8e71 into pandas-dev:master Aug 31, 2016
@jorisvandenbossche
Copy link
Member

@TomAugspurger On second thought, should the option be in pandas.options.html or in pandas.options.io.html (for consistency with excel and hdf)?
Consistency is nice, but in this case more flat options namespace is also nice (it's not that there are many entries in pd.options)

@TomAugspurger TomAugspurger deleted the border-option branch April 5, 2017 02:08
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 Output-Formatting __repr__ of pandas objects, to_string
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants