ENH: Add built-in function for Styler to format the text displayed for missing values
State: closed

As described in the issues, user who wants to control how NA values are printed
while applying styles to the output will have to implement their own formatter.
(so that the underlying data will not change and can be used for styling)

Since the behavior is common in styling (for reports etc.), suggest to add this
shortcut function to enable users format their NA values as something like '--'
or 'Not Available' easily.

EDIT:

- Change implementation to integrate with the original `.format()` using `na_rep` argument
- Add a new table-wise default `na_rep` setting, which can be set through `.set_na_rep()`
- Minor fix: formatter should be wrapped outside of locs-loop 
- Added a few user guide examples and test cases

example usage: `df.style.highlight_max().format(None, na_rep="-")`

- [x] closes #21527 and #28358
- [x] tests added / passed
- [x] passes `black pandas`
- [x] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`
- [x] whatsnew entry


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

Comments:
@topper-123 My understanding is that the "Style" tag is refers to code style, linting stuff, not the Styler class.  Do I have this backwards?
The doc has been added, please have a look! :smile:
How about the method name? do we have a conclusion?
Revision done, please help to review, thanks!  :D
I think this PR can also resolve #21527 (ENH: Styler display of NaN / null Values)
Hi @TomAugspurger, would you be available to review this PR? thanks! :wink: 
Most likely not for a couple weeks.

On Tue, Oct 29, 2019 at 9:31 AM Max Chen <notifications@github.com> wrote:

> Hi @TomAugspurger <https://github.com/TomAugspurger>, would you be
> available to review this PR? thanks! 😉
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <https://github.com/pandas-dev/pandas/pull/29118?email_source=notifications&email_token=AAKAOIR4YVQVJA2WYY3VZPDQRBCNZA5CNFSM4JCVRYEKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOECQWUEY#issuecomment-547449363>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AAKAOISPN5GHSCPUW5BP4YLQRBCNZANCNFSM4JCVRYEA>
> .
>

Ouch. :joy: 
@jreback can you help to review? :grin: 
Revision done, please have a look. :grin: 
Hi Tom, William, please have a look at the revision when you are available, thanks~
After adding the annotation for `na_rep`, mypy complained as below, so I have no choice but to add more annotations. :joy: 
```
pandas/io/formats/style.py:136: error: Need type annotation for 'ctx'
pandas/io/formats/style.py:137: error: Need type annotation for '_todo' (hint: "_todo: List[<type>] = ...")
pandas/io/formats/style.py:158: error: Need type annotation for 'hidden_columns' (hint: "hidden_columns: List[<type>] = ...")
pandas/io/formats/style.py:173: error: Need type annotation for '_display_funcs'
pandas/io/formats/style.py:470: error: "None" not callable
```
Thanks @WillAyd, I have revised using `pytest.raises` and resolve merge conflict. Since this PR is getting quite lengthy, I will try to add annotations in the follow-ups.
Hi @WillAyd, revision done for py36 type syntax, please have a look :)
Thanks @immaxchen!