BUG/API: dtype inconsistencies in .where / .setitem / .putmask / .fillna
State: closed

This fixes a number of inconsistencies and API issues w.r.t. dtype conversions. This is a reprise of #14145. This removes some code from the core structures & pushes it to internals, where the primitives are made more consistent. This should all us to be a bit more consistent for pandas2 type things.

closes #16402
supersedes #14145
supersedes #16408 
closes #14001


Labels:
name: Bug
name: Indexing
description: Related to indexing on series/frames, not to indexes themselves
name: Missing-data
description: np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate
name: API Design

Comments:
still need to update whatsnew notes. this was a PITA to make things consistent; better now.
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/16821?src=pr&el=h1) Report
> Merging [#16821](https://codecov.io/gh/pandas-dev/pandas/pull/16821?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/9e55af2552664267ce27c7fc6c932acb0651c259?src=pr&el=desc) will **increase** coverage by `<.01%`.
> The diff coverage is `94.49%`.

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

```diff
@@            Coverage Diff             @@
##           master   #16821      +/-   ##
==========================================
+ Coverage   90.94%   90.94%   +<.01%     
==========================================
  Files         161      161              
  Lines       49272    49333      +61     
==========================================
+ Hits        44811    44868      +57     
- Misses       4461     4465       +4
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `88.72% <94.49%> (ø)` | :arrow_up: |
| #single | `40.19% <31.35%> (+0.01%)` | :arrow_up: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/16821?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/indexes/numeric.py](https://codecov.io/gh/pandas-dev/pandas/pull/16821?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy9udW1lcmljLnB5) | `97.18% <100%> (+0.05%)` | :arrow_up: |
| [pandas/core/ops.py](https://codecov.io/gh/pandas-dev/pandas/pull/16821?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvb3BzLnB5) | `92.02% <100%> (ø)` | :arrow_up: |
| [pandas/core/indexes/base.py](https://codecov.io/gh/pandas-dev/pandas/pull/16821?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy9iYXNlLnB5) | `95.82% <100%> (ø)` | :arrow_up: |
| [pandas/core/dtypes/common.py](https://codecov.io/gh/pandas-dev/pandas/pull/16821?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZHR5cGVzL2NvbW1vbi5weQ==) | `94.77% <100%> (+0.02%)` | :arrow_up: |
| [pandas/core/generic.py](https://codecov.io/gh/pandas-dev/pandas/pull/16821?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZ2VuZXJpYy5weQ==) | `91.99% <100%> (-0.31%)` | :arrow_down: |
| [pandas/core/panel.py](https://codecov.io/gh/pandas-dev/pandas/pull/16821?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvcGFuZWwucHk=) | `96.91% <100%> (-0.03%)` | :arrow_down: |
| [pandas/core/algorithms.py](https://codecov.io/gh/pandas-dev/pandas/pull/16821?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYWxnb3JpdGhtcy5weQ==) | `94.45% <100%> (+0.03%)` | :arrow_up: |
| [pandas/core/frame.py](https://codecov.io/gh/pandas-dev/pandas/pull/16821?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZnJhbWUucHk=) | `97.65% <100%> (-0.01%)` | :arrow_down: |
| [pandas/core/sparse/frame.py](https://codecov.io/gh/pandas-dev/pandas/pull/16821?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvc3BhcnNlL2ZyYW1lLnB5) | `94.26% <100%> (ø)` | :arrow_up: |
| [pandas/core/internals.py](https://codecov.io/gh/pandas-dev/pandas/pull/16821?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW50ZXJuYWxzLnB5) | `93.77% <92.81%> (+0.33%)` | :arrow_up: |
| ... and [7 more](https://codecov.io/gh/pandas-dev/pandas/pull/16821?src=pr&el=tree-more) | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/16821?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/16821?src=pr&el=footer). Last update [9e55af2...b70dda9](https://codecov.io/gh/pandas-dev/pandas/pull/16821?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/16821?src=pr&el=h1) Report
> Merging [#16821](https://codecov.io/gh/pandas-dev/pandas/pull/16821?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/f511d8237322589c59eff8c16ffe00b8293ff4a1?src=pr&el=desc) will **decrease** coverage by `0.01%`.
> The diff coverage is `96.81%`.

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

```diff
@@            Coverage Diff             @@
##           master   #16821      +/-   ##
==========================================
- Coverage   91.02%      91%   -0.02%     
==========================================
  Files         161      161              
  Lines       49304    49333      +29     
==========================================
+ Hits        44879    44897      +18     
- Misses       4425     4436      +11
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `88.78% <96.81%> (ø)` | :arrow_up: |
| #single | `40.26% <38.51%> (ø)` | :arrow_up: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/16821?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/dtypes/cast.py](https://codecov.io/gh/pandas-dev/pandas/pull/16821?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZHR5cGVzL2Nhc3QucHk=) | `87.81% <100%> (+0.92%)` | :arrow_up: |
| [pandas/core/frame.py](https://codecov.io/gh/pandas-dev/pandas/pull/16821?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZnJhbWUucHk=) | `97.75% <100%> (-0.12%)` | :arrow_down: |
| [pandas/core/ops.py](https://codecov.io/gh/pandas-dev/pandas/pull/16821?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvb3BzLnB5) | `92.02% <100%> (ø)` | :arrow_up: |
| [pandas/core/panel.py](https://codecov.io/gh/pandas-dev/pandas/pull/16821?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvcGFuZWwucHk=) | `96.92% <100%> (-0.03%)` | :arrow_down: |
| [pandas/core/dtypes/common.py](https://codecov.io/gh/pandas-dev/pandas/pull/16821?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZHR5cGVzL2NvbW1vbi5weQ==) | `94.84% <100%> (+0.02%)` | :arrow_up: |
| [pandas/core/algorithms.py](https://codecov.io/gh/pandas-dev/pandas/pull/16821?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYWxnb3JpdGhtcy5weQ==) | `94.47% <100%> (+0.03%)` | :arrow_up: |
| [pandas/core/sparse/frame.py](https://codecov.io/gh/pandas-dev/pandas/pull/16821?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvc3BhcnNlL2ZyYW1lLnB5) | `94.24% <100%> (ø)` | :arrow_up: |
| [pandas/core/indexes/numeric.py](https://codecov.io/gh/pandas-dev/pandas/pull/16821?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy9udW1lcmljLnB5) | `97.18% <100%> (+0.05%)` | :arrow_up: |
| [pandas/core/generic.py](https://codecov.io/gh/pandas-dev/pandas/pull/16821?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZ2VuZXJpYy5weQ==) | `92% <100%> (-0.31%)` | :arrow_down: |
| [pandas/core/indexes/base.py](https://codecov.io/gh/pandas-dev/pandas/pull/16821?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy9iYXNlLnB5) | `95.93% <100%> (ø)` | :arrow_up: |
| ... and [11 more](https://codecov.io/gh/pandas-dev/pandas/pull/16821?src=pr&el=tree-more) | |

------

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

finally have this passing

@sinhrks @TomAugspurger if you'd have a look.
thanks for the original @sinhrks