-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
ENH: exclude html table border w/False value #45943
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
Per the HTML5 spec, border attributes on table elements are obsolete. Borders should be implemented via CSS instead. https://html.spec.whatwg.org/multipage/obsolete.html#attr-table-border This enhancement will retain the default behavior of the border keyword of to_html, but will exclude the attribute entirely upon receiving a falsy value.
Per the HTML5 spec, border attributes on table elements are obsolete. Borders should be implemented via CSS instead. https://html.spec.whatwg.org/multipage/obsolete.html#attr-table-border This enhancement will retain the default behavior of the border keyword of to_html, but will exclude the attribute entirely upon receiving a falsy value.
@github-actions pre-commit |
Excluding the border attribute upon So I have revised the enhancement to only exclude the border attribute when border=False **fixed typo |
This is one of the reasons I am trying to push
Whilst this commit solves this problem, it shouldn't be the long term solution, and its only a half measure since it still allows the old behaviour. |
… into borderless-html-tables
can you move the whatsnew note to the I/O section |
@jreback done |
This test has failed twice for reasons that I'm unclear on Code Checks / ASV Benchmarks [ 50.00%] ··· ...a.TimedeltaProperties.time_timedelta_seconds 3.80±0μs
Error: Process completed with exit code 1. |
This pull request is stale because it has been open for thirty days with no activity. Please update and respond to this comment if you're still interested in working on this. |
pls merge master |
@jreback done |
pandas/io/formats/html.py
Outdated
border = cast(int, get_option("display.html.border")) | ||
elif not border and isinstance(border, bool): |
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.
why is this instance check needed?
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.
Not my first choice, but it's to pass this test case:
(None, lambda df: df.to_html(border=0), "0"), |
Setting border=0
has to result in border="0"
being present in the output HTML. The instance check is to ensure that only a boolean can be used to hide the border.
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.
why is border=0
not de-facto the same as border=False
?
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.
In my opinion, it should be. That's how I originally wrote the fix. My only reason for taking this approach is to conform to the test case, which explicitly tests for a border attribute to be present upon border=0
.
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.
i think ok to treat these cases as the same and can simplify the code a bit
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.
Sounds good to me - I will revert to my original fix, and update that test case instead
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.
looks fine but tests are failing. ping on green
thanks @z3c0 |
Per the HTML5 spec, border attributes on table elements are obsolete.
Borders should be implemented via CSS instead.
https://html.spec.whatwg.org/multipage/obsolete.html#attr-table-border
This enhancement will retain the default behavior of the border keyword of to_html,
but will exclude the attribute entirely upon receiving a falsy value.
closes #22692