BUG: raise for invalid dtypes per issue #15520
State: closed

closes #15520 

 - [x] closes #xxxx
 - [x] tests added / passed
 - [x] passes ``git diff upstream/master --name-only -- '*.py' | flake8 --diff``
 - [x] whatsnew entry


Labels:
name: Dtype Conversions
description: Unexpected or buggy dtype conversions
name: Error Reporting
description: Incorrect or improved errors from pandas

Comments:
@jreback Updated tests as well as pandas_dtype() function as per your suggestions.
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/16047?src=pr&el=h1) Report
> Merging [#16047](https://codecov.io/gh/pandas-dev/pandas/pull/16047?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/1f16ca7a821b705010197c37b529f494060888c3?src=pr&el=desc) will **decrease** coverage by `<.01%`.
> The diff coverage is `80%`.

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

```diff
@@            Coverage Diff             @@
##           master   #16047      +/-   ##
==========================================
- Coverage   90.84%   90.84%   -0.01%     
==========================================
  Files         159      159              
  Lines       50790    50794       +4     
==========================================
+ Hits        46142    46143       +1     
- Misses       4648     4651       +3
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `88.62% <80%> (-0.01%)` | :arrow_down: |
| #single | `40.35% <60%> (-0.01%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/16047?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/dtypes/cast.py](https://codecov.io/gh/pandas-dev/pandas/pull/16047?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZHR5cGVzL2Nhc3QucHk=) | `86.89% <ø> (ø)` | :arrow_up: |
| [pandas/core/series.py](https://codecov.io/gh/pandas-dev/pandas/pull/16047?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvc2VyaWVzLnB5) | `94.97% <ø> (ø)` | :arrow_up: |
| [pandas/core/generic.py](https://codecov.io/gh/pandas-dev/pandas/pull/16047?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZ2VuZXJpYy5weQ==) | `91.29% <100%> (ø)` | :arrow_up: |
| [pandas/core/dtypes/common.py](https://codecov.io/gh/pandas-dev/pandas/pull/16047?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZHR5cGVzL2NvbW1vbi5weQ==) | `92.76% <75%> (-0.87%)` | :arrow_down: |
| [pandas/io/formats/format.py](https://codecov.io/gh/pandas-dev/pandas/pull/16047?src=pr&el=tree#diff-cGFuZGFzL2lvL2Zvcm1hdHMvZm9ybWF0LnB5) | `95.02% <0%> (-0.03%)` | :arrow_down: |
| [pandas/core/common.py](https://codecov.io/gh/pandas-dev/pandas/pull/16047?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvY29tbW9uLnB5) | `91.03% <0%> (+0.34%)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/16047?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/16047?src=pr&el=footer). Last update [1f16ca7...1f553e2](https://codecov.io/gh/pandas-dev/pandas/pull/16047?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/16047?src=pr&el=h1) Report
> Merging [#16047](https://codecov.io/gh/pandas-dev/pandas/pull/16047?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/8d122e633a6b08e3f9dfad80050da42d789210d4?src=pr&el=desc) will **decrease** coverage by `0.02%`.
> The diff coverage is `100%`.

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

```diff
@@            Coverage Diff             @@
##           master   #16047      +/-   ##
==========================================
- Coverage   90.86%   90.83%   -0.03%     
==========================================
  Files         159      159              
  Lines       50771    50779       +8     
==========================================
- Hits        46133    46127       -6     
- Misses       4638     4652      +14
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `88.61% <100%> (-0.03%)` | :arrow_down: |
| #single | `40.32% <66.66%> (-0.02%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/16047?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/dtypes/common.py](https://codecov.io/gh/pandas-dev/pandas/pull/16047?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZHR5cGVzL2NvbW1vbi5weQ==) | `93.24% <100%> (-0.39%)` | :arrow_down: |
| [pandas/core/generic.py](https://codecov.io/gh/pandas-dev/pandas/pull/16047?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZ2VuZXJpYy5weQ==) | `91.29% <100%> (ø)` | :arrow_up: |
| [pandas/core/series.py](https://codecov.io/gh/pandas-dev/pandas/pull/16047?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvc2VyaWVzLnB5) | `94.98% <100%> (ø)` | :arrow_up: |
| [pandas/core/dtypes/cast.py](https://codecov.io/gh/pandas-dev/pandas/pull/16047?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZHR5cGVzL2Nhc3QucHk=) | `86.89% <100%> (ø)` | :arrow_up: |
| [pandas/plotting/\_converter.py](https://codecov.io/gh/pandas-dev/pandas/pull/16047?src=pr&el=tree#diff-cGFuZGFzL3Bsb3R0aW5nL19jb252ZXJ0ZXIucHk=) | `63.54% <0%> (-1.82%)` | :arrow_down: |

------

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

@jreback Can this PR be reviewed please?
this is ok for 0.20.0, pls add a whatsnew note (bug fix section is fine).
@jreback Added the whatsnew note.
add a test for the original issue as well

``pd.Series([], name='time',dtype=pd.Timestamp)``
which works (should raise)
@jreback Should I add the test in `core/tests/series/test_dtypes.py`?
put in ``tests/series/test_constructors`` I think (this is an additional test), leave what you have
@jreback Anything else which is missing?
thanks @analyticalmonk 

nice fixes!

keem em coming!