Support dicts with default values in series.map
State: closed

Closes https://github.com/pandas-dev/pandas/issues/15999

Still a work in progress.

Labels:
name: Enhancement
name: Missing-data
description: np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate

Comments:
*always* write the tests first!
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/16002?src=pr&el=h1) Report
> Merging [#16002](https://codecov.io/gh/pandas-dev/pandas/pull/16002?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/2d9451ddc36c194f1d65dab7568901c9ea998002?src=pr&el=desc) will **increase** coverage by `<.01%`.
> The diff coverage is `100%`.

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

```diff
@@            Coverage Diff             @@
##           master   #16002      +/-   ##
==========================================
+ Coverage   91.02%   91.02%   +<.01%     
==========================================
  Files         145      145              
  Lines       50391    50394       +3     
==========================================
+ Hits        45870    45873       +3     
  Misses       4521     4521
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `88.83% <100%> (ø)` | :arrow_up: |
| #single | `40.33% <40%> (-0.01%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/16002?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/series.py](https://codecov.io/gh/pandas-dev/pandas/pull/16002?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvc2VyaWVzLnB5) | `95.09% <100%> (+0.01%)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/16002?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/16002?src=pr&el=footer). Last update [2d9451d...79cfd11](https://codecov.io/gh/pandas-dev/pandas/pull/16002?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
> _always_ write the tests first!

@jreback good idea (assuming this is so we can check that the tests fail before the enhancement).

I rebased to put the testing commit first. Unfortunately, the GitHub PR displays orders by commit time rather than order. Also CI is only building the tip commit.
u need to duck type the test rather than hard coding things
> u need to duck type the test rather than hard coding things

I dug a bit deeper. The [`__missing__`](https://docs.python.org/3.6/reference/datamodel.html#object.__missing__) method is how dict subclasses can return default values. Switched to this method in 961ea46ec21d5842b87471d57563336caa61f19f.
great 

make sure to test a dict subclass with and w/o missimg 

document in doc string

add a note in other api changes section 
small comments, other lgtm.
Confirmed locally that the following tests fail under the old code for `Series.map` by running `py.test --quiet pandas/tests/series/test_apply.py`:

+ `TestSeriesMap.test_map_counter`
+ `TestSeriesMap.test_map_defaultdict`
+ `TestSeriesMap.test_map_dict_subclass_with_missing`

Removing WIP from title.
couple minor doc comments. ping on green.
```
>>> "It's \N{green apple}"
"It's 🍏"
```

@jreback also known as PR is passing all checks
thanks!