BUG: Improve col_space in to_html to allow css length strings (#25941)
State: closed

- [x] closes #25941
- [x] tests added / passed
- [x] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`
- [x] whatsnew entry

Adds the ability to pass a string as the `col_space` parameter in `to_html`.

For backwards compatibility and similarity for other `to_*` functions, I kept in the ability to pass an `int`.  The `int` is automatically turned into `px` units (I chose `px` because that is the default if you put a unit-less CSS length into chrome).  If you want that removed and to always expect a string, let me know.

Labels:
name: Code Style
description: Code style, linting, code_checks

Comments:
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/26012?src=pr&el=h1) Report
> Merging [#26012](https://codecov.io/gh/pandas-dev/pandas/pull/26012?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/a1fee9199eba7ebf423880243936b9f1501d3d3a?src=pr&el=desc) will **decrease** coverage by `<.01%`.
> The diff coverage is `100%`.

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

```diff
@@            Coverage Diff             @@
##           master   #26012      +/-   ##
==========================================
- Coverage   91.82%   91.81%   -0.01%     
==========================================
  Files         175      175              
  Lines       52551    52553       +2     
==========================================
- Hits        48256    48254       -2     
- Misses       4295     4299       +4
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.38% <100%> (ø)` | :arrow_up: |
| #single | `40.72% <16.66%> (-0.14%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/26012?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/io/formats/format.py](https://codecov.io/gh/pandas-dev/pandas/pull/26012/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2Zvcm1hdHMvZm9ybWF0LnB5) | `97.89% <ø> (ø)` | :arrow_up: |
| [pandas/io/formats/html.py](https://codecov.io/gh/pandas-dev/pandas/pull/26012/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2Zvcm1hdHMvaHRtbC5weQ==) | `99.36% <100%> (ø)` | :arrow_up: |
| [pandas/core/frame.py](https://codecov.io/gh/pandas-dev/pandas/pull/26012/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZnJhbWUucHk=) | `96.79% <100%> (-0.12%)` | :arrow_down: |
| [pandas/io/gbq.py](https://codecov.io/gh/pandas-dev/pandas/pull/26012/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2dicS5weQ==) | `75% <0%> (-12.5%)` | :arrow_down: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/26012?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/26012?src=pr&el=footer). Last update [a1fee91...36f872c](https://codecov.io/gh/pandas-dev/pandas/pull/26012?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/26012?src=pr&el=h1) Report
> Merging [#26012](https://codecov.io/gh/pandas-dev/pandas/pull/26012?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/2f6b90aaaab6814c102eb160c5a9c11bc04a092e?src=pr&el=desc) will **increase** coverage by `0.12%`.
> The diff coverage is `100%`.

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

```diff
@@            Coverage Diff             @@
##           master   #26012      +/-   ##
==========================================
+ Coverage   91.84%   91.97%   +0.12%     
==========================================
  Files         175      175              
  Lines       52517    52374     -143     
==========================================
- Hits        48233    48169      -64     
+ Misses       4284     4205      -79
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.52% <100%> (+0.13%)` | :arrow_up: |
| #single | `40.69% <25%> (-0.16%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/26012?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/io/formats/format.py](https://codecov.io/gh/pandas-dev/pandas/pull/26012/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2Zvcm1hdHMvZm9ybWF0LnB5) | `97.9% <ø> (+0.01%)` | :arrow_up: |
| [pandas/io/formats/html.py](https://codecov.io/gh/pandas-dev/pandas/pull/26012/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2Zvcm1hdHMvaHRtbC5weQ==) | `99.36% <100%> (ø)` | :arrow_up: |
| [pandas/core/frame.py](https://codecov.io/gh/pandas-dev/pandas/pull/26012/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZnJhbWUucHk=) | `96.9% <100%> (-0.01%)` | :arrow_down: |
| [pandas/util/\_doctools.py](https://codecov.io/gh/pandas-dev/pandas/pull/26012/diff?src=pr&el=tree#diff-cGFuZGFzL3V0aWwvX2RvY3Rvb2xzLnB5) | `0% <0%> (-12.88%)` | :arrow_down: |
| [pandas/io/gbq.py](https://codecov.io/gh/pandas-dev/pandas/pull/26012/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2dicS5weQ==) | `78.94% <0%> (-8.56%)` | :arrow_down: |
| [pandas/core/indexing.py](https://codecov.io/gh/pandas-dev/pandas/pull/26012/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhpbmcucHk=) | `90.53% <0%> (-0.35%)` | :arrow_down: |
| [pandas/core/sparse/frame.py](https://codecov.io/gh/pandas-dev/pandas/pull/26012/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvc3BhcnNlL2ZyYW1lLnB5) | `95.49% <0%> (-0.21%)` | :arrow_down: |
| [pandas/core/computation/engines.py](https://codecov.io/gh/pandas-dev/pandas/pull/26012/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvY29tcHV0YXRpb24vZW5naW5lcy5weQ==) | `88.33% <0%> (-0.2%)` | :arrow_down: |
| [pandas/util/testing.py](https://codecov.io/gh/pandas-dev/pandas/pull/26012/diff?src=pr&el=tree#diff-cGFuZGFzL3V0aWwvdGVzdGluZy5weQ==) | `90.61% <0%> (-0.12%)` | :arrow_down: |
| [pandas/tseries/holiday.py](https://codecov.io/gh/pandas-dev/pandas/pull/26012/diff?src=pr&el=tree#diff-cGFuZGFzL3RzZXJpZXMvaG9saWRheS5weQ==) | `93.1% <0%> (-0.11%)` | :arrow_down: |
| ... and [83 more](https://codecov.io/gh/pandas-dev/pandas/pull/26012/diff?src=pr&el=tree-more) | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/26012?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/26012?src=pr&el=footer). Last update [2f6b90a...1bcc5c6](https://codecov.io/gh/pandas-dev/pandas/pull/26012?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

Hello @ArtificialQualia! Thanks for updating this PR. We checked the lines you've touched for [PEP 8](https://www.python.org/dev/peps/pep-0008) issues, and found:









There are currently no PEP 8 issues detected in this Pull Request. Cheers! :beers: 

##### Comment last updated at 2019-04-28 19:40:53 UTC
> For backwards compatibility and similarity for other `to_*` functions, I kept in the ability to pass an `int`. The `int` is automatically turned into `px` units (I chose `px` because that is the default if you put a unit-less CSS length into chrome). If you want that removed and to always expect a string, let me know.

it makes sense to just be px, since the parameter is applied to all columns % makes less sense. 
Anything more needed on this PR?
lgtm. @WillAyd
Thanks @ArtificialQualia !