to_html formatter not called for float values in a mixed-type column (2)
State: closed

- [x] closes #13021
- [x] tests added / passed
- [x] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`
- [x] whatsnew entry


resubmit of #25983

Labels:
name: Output-Formatting
description: __repr__ of pandas objects, to_string
name: IO HTML
description: read_html, to_html, Styler.apply, Styler.applymap

Comments:
considering https://github.com/pandas-dev/pandas/pull/24134#discussion_r240038431 , this PR may need to revert some of #24134 which i think caused the regression in #25984
i'm going to close this for now, since while the implementation of `ExtensionArrayFormatter` relies on formatting options AND a `formatters` parameter, it is not possible to add the shortcut for custom formatters. Changing this is outside the scope of this PR so i'll circle back to this once that's resolved.
@jreback ; gone with bypassing `format_array` altogether when `formatters` are passed . it's a bit hacky, but on the bright side it closes the original issue, gets round the leading space bug #26002 and gets an additional test in play.
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/26000?src=pr&el=h1) Report
> :exclamation: No coverage uploaded for pull request base (`master@77e6556`). [Click here to learn what that means](https://docs.codecov.io/docs/error-reference#section-missing-base-commit).
> The diff coverage is `100%`.

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

```diff
@@            Coverage Diff            @@
##             master   #26000   +/-   ##
=========================================
  Coverage          ?   91.86%           
=========================================
  Files             ?      180           
  Lines             ?    50717           
  Branches          ?        0           
=========================================
  Hits              ?    46592           
  Misses            ?     4125           
  Partials          ?        0
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.46% <100%> (?)` | |
| #single | `41.1% <50%> (?)` | |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/26000?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/io/formats/format.py](https://codecov.io/gh/pandas-dev/pandas/pull/26000/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2Zvcm1hdHMvZm9ybWF0LnB5) | `98.02% <100%> (ø)` | |
| [pandas/core/arrays/integer.py](https://codecov.io/gh/pandas-dev/pandas/pull/26000/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYXJyYXlzL2ludGVnZXIucHk=) | `96.3% <100%> (ø)` | |
| [pandas/core/arrays/interval.py](https://codecov.io/gh/pandas-dev/pandas/pull/26000/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYXJyYXlzL2ludGVydmFsLnB5) | `93.1% <100%> (ø)` | |
| [pandas/core/arrays/categorical.py](https://codecov.io/gh/pandas-dev/pandas/pull/26000/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYXJyYXlzL2NhdGVnb3JpY2FsLnB5) | `95.92% <100%> (ø)` | |
| [pandas/core/indexes/base.py](https://codecov.io/gh/pandas-dev/pandas/pull/26000/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy9iYXNlLnB5) | `96.71% <100%> (ø)` | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/26000?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/26000?src=pr&el=footer). Last update [77e6556...5ecf91a](https://codecov.io/gh/pandas-dev/pandas/pull/26000?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/26000?src=pr&el=h1) Report
> Merging [#26000](https://codecov.io/gh/pandas-dev/pandas/pull/26000?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/181f972d2f4e6bd5c8c33721175f68188cfa1a0d?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/26000/graphs/tree.svg?width=650&token=eZ4WkYLtcO&height=150&src=pr)](https://codecov.io/gh/pandas-dev/pandas/pull/26000?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master   #26000      +/-   ##
==========================================
- Coverage   91.82%   91.82%   -0.01%     
==========================================
  Files         175      175              
  Lines       52551    52555       +4     
==========================================
+ Hits        48256    48257       +1     
- Misses       4295     4298       +3
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.38% <100%> (ø)` | :arrow_up: |
| #single | `40.74% <50%> (-0.12%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/26000?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/io/formats/format.py](https://codecov.io/gh/pandas-dev/pandas/pull/26000/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2Zvcm1hdHMvZm9ybWF0LnB5) | `97.9% <100%> (ø)` | :arrow_up: |
| [pandas/io/gbq.py](https://codecov.io/gh/pandas-dev/pandas/pull/26000/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2dicS5weQ==) | `75% <0%> (-12.5%)` | :arrow_down: |
| [pandas/core/frame.py](https://codecov.io/gh/pandas-dev/pandas/pull/26000/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZnJhbWUucHk=) | `96.79% <0%> (-0.12%)` | :arrow_down: |
| [pandas/util/testing.py](https://codecov.io/gh/pandas-dev/pandas/pull/26000/diff?src=pr&el=tree#diff-cGFuZGFzL3V0aWwvdGVzdGluZy5weQ==) | `90.72% <0%> (+0.1%)` | :arrow_up: |

------

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

@simonjayhawkins can you merge master, what's the status?
> @simonjayhawkins can you merge master, what's the status?

changing ExtensionArrayFormatter is necessary but outside the scope of this PR.

did make a change here in this PR and ci passing. I think that is more an indication of missing tests than a solution.

will do a precursor PR instead. I'm not really happy with the implementation of ExtensionArrayFormatter but don't know why it was done this way. There presumably needs to a mechanism for 3rd party creators of EA types to display a repr. not sure if this was the reason and that is the solution though.
> while the implementation of `ExtensionArrayFormatter` relies on formatting options AND a `formatters` parameter, it is not possible to add the shortcut for custom formatters.

changed formatters to be a pre-formatter instead of a shortcut so this is no longer an issue. @jorisvandenbossche 
latest commit also closes #26002 (again), two spaces between columns now as for other DataFrame columns
lgtm. @jorisvandenbossche @TomAugspurger if you want to have a look.
@simonjayhawkins is this orthogonal to your formatters refactor?
@jreback 

The two PRs are addressing orthogonal issues, but the implementations are not 100% orthogonal.

The other PR is a more important issue. This PR addresses a case which is probably rarely encountered by users.

This should probably be put on hold while the Extension Array formatting is discussed, since this PR does change some Extension Array formatting code.

I could probably pull out a couple of these changes into a separate PR. Changing the formatter parameter to format_array to be optional is probably not contentious and adding a test for na_rep of IntegarNA would be a good thing.
@simonjayhawkins there's a merge conflict.

Is this ready for 0.25? Haven't had time to look at the change, but I'm happy to trust others if the tests are passing.

> Is this ready for 0.25?

i don't believe it is wise to merge this at this time, so closing for now and will revisit at a later date.