ENH: Add Styler.where
State: closed

- [x] closes #16255
- [x] tests added / passed
Added `test_where_subset` in `pandas/tests/io/formats/test_style.py`.
- [x] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`
- [x] whatsnew entry
It makes the redundant style condition simple.
```python
df.style.applymap(lambda val: 'color: %s' % 'red' if val < 0 else 'black')
df.style.where(lambda val: val < 0, 'color: red', 'color: black')
```

Labels:
name: Output-Formatting
description: __repr__ of pandas objects, to_string

Comments:
Hello @Licht-T! Thanks for updating the PR.





Cheers ! There are no PEP8 issues in this Pull Request. :beers: 

##### Comment last updated on September 10, 2017 at 14:48 Hours UTC
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/17474?src=pr&el=h1) Report
> Merging [#17474](https://codecov.io/gh/pandas-dev/pandas/pull/17474?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/7e4e8acf5b5d68b3dfadecd3ba816d4f0b9be0ce?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/17474/graphs/tree.svg?width=650&token=eZ4WkYLtcO&height=150&src=pr)](https://codecov.io/gh/pandas-dev/pandas/pull/17474?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master   #17474      +/-   ##
==========================================
- Coverage   91.16%   91.14%   -0.02%     
==========================================
  Files         163      163              
  Lines       49561    49561              
==========================================
- Hits        45180    45171       -9     
- Misses       4381     4390       +9
```

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

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

------

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

```diff
@@            Coverage Diff             @@
##           master   #17474      +/-   ##
==========================================
- Coverage   91.15%   91.13%   -0.02%     
==========================================
  Files         163      163              
  Lines       49534    49534              
==========================================
- Hits        45153    45144       -9     
- Misses       4381     4390       +9
```

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

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

------

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

@jreback @TomAugspurger Thanks for your review. Fixed and added some new tests.
Travis CI seems not work well due to its own error.
Could someone restart the Travis CI build?
@jreback Thanks for your suggestion. Fixed!
@jreback Thanks. All is now fixed.
thanks @Licht-T 

If you'd have a pass thru the actual documentation notebook and make a PR for anything where we should logically use ``.where`` to make the syntax more clear would be great (or indicate that it looks good).