Styler.to_html implemented for outputting styled DataFrame as HTML
State: closed

- [ ] closes #xxxx
- [x] tests added / passed
- [x] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`
- [x] whatsnew entry

Added a very simple `Style.to_html` helper function for outputting a styled DataFrame to an HTML file.


Labels:
name: Enhancement
name: IO HTML
description: read_html, to_html, Styler.apply, Styler.applymap

Comments:
Hello @apryor6! Thanks for updating the PR.



 - In the file [`pandas/tests/io/formats/test_to_html.py`](https://github.com/pandas-dev/pandas/blob/5026e904596f2aec10382e2efe1eb201f224c1f9/pandas/tests/io/formats/test_to_html.py), following are the PEP8 issues :

> [Line 1923:17](https://github.com/pandas-dev/pandas/blob/5026e904596f2aec10382e2efe1eb201f224c1f9/pandas/tests/io/formats/test_to_html.py#L1923): [E225](https://duckduckgo.com/?q=pep8%20E225) missing whitespace around operator
> [Line 1925:21](https://github.com/pandas-dev/pandas/blob/5026e904596f2aec10382e2efe1eb201f224c1f9/pandas/tests/io/formats/test_to_html.py#L1925): [W291](https://duckduckgo.com/?q=pep8%20W291) trailing whitespace



##### Comment last updated on September 19, 2017 at 21:00 Hours UTC
@apryor6 : Is there a reason why you keep pushing pep8 fixes?  You should probably try to check them locally first before pushing.
I rebased all the frivolous pep8 commits -- should be okay now.
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/17545?src=pr&el=h1) Report
> Merging [#17545](https://codecov.io/gh/pandas-dev/pandas/pull/17545?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/328c7e179b72e257e27adf92a06718fd5a40473f?src=pr&el=desc) will **decrease** coverage by `0.01%`.
> The diff coverage is `n/a`.

[![Impacted file tree graph](https://codecov.io/gh/pandas-dev/pandas/pull/17545/graphs/tree.svg?token=eZ4WkYLtcO&src=pr&height=150&width=650)](https://codecov.io/gh/pandas-dev/pandas/pull/17545?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master   #17545      +/-   ##
==========================================
- Coverage   91.25%   91.23%   -0.02%     
==========================================
  Files         163      163              
  Lines       49606    49606              
==========================================
- Hits        45266    45257       -9     
- Misses       4340     4349       +9
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `89.01% <ø> (ø)` | :arrow_up: |
| #single | `40.19% <ø> (-0.07%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/17545?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/io/formats/style.py](https://codecov.io/gh/pandas-dev/pandas/pull/17545?src=pr&el=tree#diff-cGFuZGFzL2lvL2Zvcm1hdHMvc3R5bGUucHk=) | `100% <ø> (ø)` | :arrow_up: |
| [pandas/io/gbq.py](https://codecov.io/gh/pandas-dev/pandas/pull/17545?src=pr&el=tree#diff-cGFuZGFzL2lvL2dicS5weQ==) | `25% <0%> (-58.34%)` | :arrow_down: |
| [pandas/core/frame.py](https://codecov.io/gh/pandas-dev/pandas/pull/17545?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZnJhbWUucHk=) | `97.77% <0%> (-0.1%)` | :arrow_down: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/17545?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/17545?src=pr&el=footer). Last update [328c7e1...005e215](https://codecov.io/gh/pandas-dev/pandas/pull/17545?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/17545?src=pr&el=h1) Report
> Merging [#17545](https://codecov.io/gh/pandas-dev/pandas/pull/17545?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/328c7e179b72e257e27adf92a06718fd5a40473f?src=pr&el=desc) will **decrease** coverage by `0.01%`.
> The diff coverage is `n/a`.

[![Impacted file tree graph](https://codecov.io/gh/pandas-dev/pandas/pull/17545/graphs/tree.svg?token=eZ4WkYLtcO&width=650&src=pr&height=150)](https://codecov.io/gh/pandas-dev/pandas/pull/17545?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master   #17545      +/-   ##
==========================================
- Coverage   91.25%   91.23%   -0.02%     
==========================================
  Files         163      163              
  Lines       49606    49606              
==========================================
- Hits        45266    45257       -9     
- Misses       4340     4349       +9
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `89.01% <ø> (ø)` | :arrow_up: |
| #single | `40.19% <ø> (-0.07%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/17545?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/io/formats/style.py](https://codecov.io/gh/pandas-dev/pandas/pull/17545?src=pr&el=tree#diff-cGFuZGFzL2lvL2Zvcm1hdHMvc3R5bGUucHk=) | `100% <ø> (ø)` | :arrow_up: |
| [pandas/io/gbq.py](https://codecov.io/gh/pandas-dev/pandas/pull/17545?src=pr&el=tree#diff-cGFuZGFzL2lvL2dicS5weQ==) | `25% <0%> (-58.34%)` | :arrow_down: |
| [pandas/core/frame.py](https://codecov.io/gh/pandas-dev/pandas/pull/17545?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZnJhbWUucHk=) | `97.77% <0%> (-0.1%)` | :arrow_down: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/17545?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/17545?src=pr&el=footer). Last update [328c7e1...5026e90](https://codecov.io/gh/pandas-dev/pandas/pull/17545?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

I think the only main thing missing is the different encoding behavior for py2/py3 -- what's the preferred way to check python version? the `encoding` argument for `open` is not supported in py2
For checking, it'd be `from pandas.compat import PY2`.

I think in python 2 you can pass an encoding to codecs.open.

On Tue, Sep 19, 2017 at 4:03 PM, Alan (AJ) Pryor, Jr. <
notifications@github.com> wrote:

> I think the only main thing missing is the different encoding behavior for
> py2/py3 -- what's the preferred way to check python version? the encoding
> argument for open is not supported in py2
>
> —
> You are receiving this because you commented.
> Reply to this email directly, view it on GitHub
> <https://github.com/pandas-dev/pandas/pull/17545#issuecomment-330672861>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/ABQHIjFuEEeFawtcDZ_atmLelDGAlBmCks5skCwrgaJpZM4PZK-p>
> .
>

can you rebase and update to comments
closing as stale. if you want to continue working, pls ping.