CLN: use idiomatic pandas_dtypes in pandas/dtypes/common.py
State: closed

closes #24593 

Some benchmarks of ``pandas_dtype`` construction from a dtype object & strings, only thing slightly suprising is ``Period[D]``
```
[ 87.50%] ··· ============================================ =============
                                 dtype                                  
              -------------------------------------------- -------------
                             dtype('int64')                   463±20ns  
                             dtype('int32')                   450±20ns  
                            dtype('uint32')                   444±4ns   
                            dtype('uint64')                   484±20ns  
                            dtype('float32')                  494±30ns  
                            dtype('float64')                  507±30ns  
                             dtype('int16')                   471±30ns  
                             dtype('int8')                    506±30ns  
                            dtype('uint16')                   505±40ns  
                             dtype('uint8')                   485±20ns  
                              dtype('<M8')                    451±20ns  
                              dtype('<m8')                    480±20ns  
                               dtype('O')                    627±200ns  
                  pandas.core.arrays.integer.Int8Dtype        995±60ns  
                 pandas.core.arrays.integer.Int16Dtype        944±60ns  
                 pandas.core.arrays.integer.Int32Dtype        939±70ns  
                 pandas.core.arrays.integer.Int64Dtype        988±30ns  
                 pandas.core.arrays.integer.UInt8Dtype        924±50ns  
                 pandas.core.arrays.integer.UInt16Dtype       954±60ns  
                 pandas.core.arrays.integer.UInt32Dtype       966±70ns  
                 pandas.core.arrays.integer.UInt64Dtype     1.00±0.06μs 
               pandas.core.dtypes.dtypes.CategoricalDtype     978±30ns  
                pandas.core.dtypes.dtypes.IntervalDtype      929±300ns  
                          datetime64[ns, UTC]               1.52±0.03μs 
                               period[D]                      958±9ns   
                                 int64                       16.1±0.1μs 
                                 int32                       16.1±0.6μs 
                                 uint32                      16.0±0.1μs 
                                 uint64                      16.2±0.3μs 
                                float32                      15.8±0.4μs 
                                float64                      15.7±0.6μs 
                                 int16                       16.0±0.2μs 
                                  int8                      15.7±0.06μs 
                                 uint16                     15.9±0.08μs 
                                 uint8                       17.3±0.6μs 
                               datetime64                    16.2±0.3μs 
                              timedelta64                    16.0±0.1μs 
                                 object                      16.0±0.2μs 
                                  Int8                       6.24±0.1μs 
                                 Int16                       7.41±0.2μs 
                                 Int32                      8.15±0.04μs 
                                 Int64                       9.39±0.1μs 
                                 UInt8                       10.1±0.1μs 
                                 UInt16                     11.0±0.04μs 
                                 UInt32                      11.8±0.5μs 
                                 UInt64                     12.7±0.08μs 
                                category                    2.62±0.03μs 
                                interval                     6.72±0.2μs 
                          datetime64[ns, UTC]                2.93±0.1μs 
                               period[D]                     52.6±0.6μs 
              ============================================ =============
```

Labels:
name: Dtype Conversions
description: Unexpected or buggy dtype conversions
name: Clean

Comments:
cc @TomAugspurger @jbrockmendel 

should be orthogonal to anything you are doing.
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/24541?src=pr&el=h1) Report
> Merging [#24541](https://codecov.io/gh/pandas-dev/pandas/pull/24541?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/cf922304a16b1d4539b841f56ab2a83496a80384?src=pr&el=desc) will **decrease** coverage by `<.01%`.
> The diff coverage is `98.38%`.

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

```diff
@@            Coverage Diff             @@
##           master   #24541      +/-   ##
==========================================
- Coverage   92.32%   92.32%   -0.01%     
==========================================
  Files         166      166              
  Lines       52440    52368      -72     
==========================================
- Hits        48417    48349      -68     
+ Misses       4023     4019       -4
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.74% <98.38%> (-0.01%)` | :arrow_down: |
| #single | `42.98% <80.64%> (-0.03%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/24541?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/indexes/numeric.py](https://codecov.io/gh/pandas-dev/pandas/pull/24541/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy9udW1lcmljLnB5) | `97.32% <100%> (ø)` | :arrow_up: |
| [pandas/core/internals/construction.py](https://codecov.io/gh/pandas-dev/pandas/pull/24541/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW50ZXJuYWxzL2NvbnN0cnVjdGlvbi5weQ==) | `96.67% <100%> (ø)` | :arrow_up: |
| [pandas/core/dtypes/common.py](https://codecov.io/gh/pandas-dev/pandas/pull/24541/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZHR5cGVzL2NvbW1vbi5weQ==) | `96.2% <98.24%> (+0.57%)` | :arrow_up: |
| [pandas/util/testing.py](https://codecov.io/gh/pandas-dev/pandas/pull/24541/diff?src=pr&el=tree#diff-cGFuZGFzL3V0aWwvdGVzdGluZy5weQ==) | `87.59% <0%> (-0.1%)` | :arrow_down: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/24541?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/24541?src=pr&el=footer). Last update [cf92230...053c14a](https://codecov.io/gh/pandas-dev/pandas/pull/24541?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/24541?src=pr&el=h1) Report
> Merging [#24541](https://codecov.io/gh/pandas-dev/pandas/pull/24541?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/6249355b853878ff06ad8d2affe00d3b629a36ea?src=pr&el=desc) will **decrease** coverage by `<.01%`.
> The diff coverage is `98.68%`.

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

```diff
@@            Coverage Diff             @@
##           master   #24541      +/-   ##
==========================================
- Coverage   92.38%   92.38%   -0.01%     
==========================================
  Files         166      166              
  Lines       52490    52396      -94     
==========================================
- Hits        48493    48404      -89     
+ Misses       3997     3992       -5
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.8% <98.68%> (-0.01%)` | :arrow_down: |
| #single | `42.98% <71.05%> (-0.07%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/24541?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/frame.py](https://codecov.io/gh/pandas-dev/pandas/pull/24541/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZnJhbWUucHk=) | `96.92% <ø> (ø)` | :arrow_up: |
| [pandas/core/dtypes/concat.py](https://codecov.io/gh/pandas-dev/pandas/pull/24541/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZHR5cGVzL2NvbmNhdC5weQ==) | `96.6% <100%> (-0.04%)` | :arrow_down: |
| [pandas/core/arrays/integer.py](https://codecov.io/gh/pandas-dev/pandas/pull/24541/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYXJyYXlzL2ludGVnZXIucHk=) | `96.32% <100%> (+0.02%)` | :arrow_up: |
| [pandas/core/dtypes/cast.py](https://codecov.io/gh/pandas-dev/pandas/pull/24541/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZHR5cGVzL2Nhc3QucHk=) | `88.72% <100%> (ø)` | :arrow_up: |
| [pandas/core/indexes/numeric.py](https://codecov.io/gh/pandas-dev/pandas/pull/24541/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy9udW1lcmljLnB5) | `97.32% <100%> (ø)` | :arrow_up: |
| [pandas/core/internals/concat.py](https://codecov.io/gh/pandas-dev/pandas/pull/24541/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW50ZXJuYWxzL2NvbmNhdC5weQ==) | `96.45% <100%> (-0.37%)` | :arrow_down: |
| [pandas/core/internals/construction.py](https://codecov.io/gh/pandas-dev/pandas/pull/24541/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW50ZXJuYWxzL2NvbnN0cnVjdGlvbi5weQ==) | `96.68% <100%> (ø)` | :arrow_up: |
| [pandas/core/dtypes/common.py](https://codecov.io/gh/pandas-dev/pandas/pull/24541/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZHR5cGVzL2NvbW1vbi5weQ==) | `96.78% <98.43%> (+1.66%)` | :arrow_up: |
| [pandas/core/internals/blocks.py](https://codecov.io/gh/pandas-dev/pandas/pull/24541/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW50ZXJuYWxzL2Jsb2Nrcy5weQ==) | `94.21% <0%> (-0.33%)` | :arrow_down: |
| ... and [8 more](https://codecov.io/gh/pandas-dev/pandas/pull/24541/diff?src=pr&el=tree-more) | |

------

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

@jbrockmendel if any comments
A few comments, one possible request for a test.  Otherwise LGTM.
updated
i have a couple of more changes here.
ill take a look
@jbrockmendel if any more comments
> Does this change the behaviour of is_integer_dtype (getting that from one of your comments). Currently that returns False for Integer64Dtype. Not sure we should change that (code could rely on the fact there would be no NaNs for integers).

yes this was broken before
@jbrockmendel I think you had another comment but can't find it.
I think the only other comment that may have gotten lost was a suggestion to do the `cond=lambda x: issubclass(...)` in one place and avoid having all the lambdas.
> > Does this change the behaviour of is_integer_dtype (getting that from one of your comments). Currently that returns False for Integer64Dtype. Not sure we should change that (code could rely on the fact there would be no NaNs for integers).
>
> yes this was broken before

It could also have been a choice :)

In any case, can you then update the docstring of `is_integer_dtype` to reflect this change? (is `is_int64_dtype` also affected?)
ok this is ready. @jorisvandenbossche @jbrockmendel 
LGTM.

The part I'm least familiar with is the IntNA, so grain of salt.

Side-note: will this fix these warnings I get in the test logs?

```
pandas/core/dtypes/common.py:1864
  [...]pandas/core/dtypes/common.py:1864: DeprecationWarning: Numeric-style type codes are deprecated and will result in an error in the future.
    return _get_dtype_type(np.dtype(arr_or_dtype))
```
yes those warnings are gone
So I think this closes https://github.com/pandas-dev/pandas/issues/24593 then?
yes this closes #24593 as well. will address comments later today.
> yes this closes #24593 as wel

There are still a bunch of those deprecation warnings in the last travis build in this PR (although maybe coming from another place, that I didn't check. But strictly speaking not yet closing ##24593 completely)
@jorisvandenbossche where? https://github.com/pandas-dev/pandas/pull/24541#issuecomment-451303579
Eg https://travis-ci.org/pandas-dev/pandas/jobs/474964674 (first entry of the last green travis build at the time I commented before) still has some "eprecationWarning: Numeric-style type codes are deprecated and will result in an error in the future." warnings in the log
I updated the whatsnew about #21681 as well.
ok warnings fixed up. Basically we were missing paths in core/internals/concat.py and core/dtypes/conat.py for EA operations.