Added tests for _get_dtype
State: closed

 - [ ] closes #xxxx
 - [ x] tests added / passed
 - [ ] passes ``git diff upstream/master --name-only -- '*.py' | flake8 --diff`` (On Windows, ``git diff upstream/master -u -- "*.py" | flake8 --diff`` might work as an alternative.)
 - [ ] whatsnew entry

See #16817 for a discussion on this.

Added tests for `` pd.core.dtypes.common._get_dtype``. Some things to note:
* Tests for Categoricals fail, I've marked them xfail. This is because I propose allowing categoricals to pass in a later commit.
* ``Interval``s don't have a dtype, so they'd fail with an AttributeError. I therefore haven't added tests for Intervals, but it could be considered if it's a bug/inconsistency, that ``Interval``s don't have a dtype.

This is my first serious pull request, and I may have made errors. If anything is wrong, against the style guide,etc. please let me know.

I will make a pull request of tests for ``_get_dtype_type``, when this one has been accepted.


Labels:
name: Testing
description: pandas testing functions or related to the test suite
name: Dtype Conversions
description: Unexpected or buggy dtype conversions

Comments:
you have some linting issues, try 

``git diff upstream/master --name-only -- '*.py' | flake8 --diff``

to see them


# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/16845?src=pr&el=h1) Report
> Merging [#16845](https://codecov.io/gh/pandas-dev/pandas/pull/16845?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/7d0a98e9bfb6c59d5f1738927732ddb80013b581?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/16845/graphs/tree.svg?width=650&height=150&token=eZ4WkYLtcO&src=pr)](https://codecov.io/gh/pandas-dev/pandas/pull/16845?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master   #16845      +/-   ##
==========================================
- Coverage   90.97%   90.96%   -0.02%     
==========================================
  Files         161      161              
  Lines       49277    49277              
==========================================
- Hits        44831    44824       -7     
- Misses       4446     4453       +7
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `88.73% <ø> (ø)` | :arrow_up: |
| #single | `40.19% <ø> (-0.22%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/16845?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/io/gbq.py](https://codecov.io/gh/pandas-dev/pandas/pull/16845?src=pr&el=tree#diff-cGFuZGFzL2lvL2dicS5weQ==) | `25% <0%> (-41.67%)` | :arrow_down: |
| [pandas/core/frame.py](https://codecov.io/gh/pandas-dev/pandas/pull/16845?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZnJhbWUucHk=) | `97.66% <0%> (-0.1%)` | :arrow_down: |

------

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

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

```diff
@@            Coverage Diff             @@
##           master   #16845      +/-   ##
==========================================
- Coverage   90.97%   90.96%   -0.01%     
==========================================
  Files         161      161              
  Lines       49277    49300      +23     
==========================================
+ Hits        44831    44848      +17     
- Misses       4446     4452       +6
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `88.74% <ø> (ø)` | :arrow_up: |
| #single | `40.19% <ø> (-0.21%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/16845?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/io/gbq.py](https://codecov.io/gh/pandas-dev/pandas/pull/16845?src=pr&el=tree#diff-cGFuZGFzL2lvL2dicS5weQ==) | `25% <0%> (-41.67%)` | :arrow_down: |
| [pandas/plotting/\_timeseries.py](https://codecov.io/gh/pandas-dev/pandas/pull/16845?src=pr&el=tree#diff-cGFuZGFzL3Bsb3R0aW5nL190aW1lc2VyaWVzLnB5) | `60.2% <0%> (-1.58%)` | :arrow_down: |
| [pandas/core/frame.py](https://codecov.io/gh/pandas-dev/pandas/pull/16845?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZnJhbWUucHk=) | `97.71% <0%> (-0.05%)` | :arrow_down: |
| [pandas/core/indexes/period.py](https://codecov.io/gh/pandas-dev/pandas/pull/16845?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy9wZXJpb2QucHk=) | `92.74% <0%> (ø)` | :arrow_up: |
| [pandas/core/indexes/timedeltas.py](https://codecov.io/gh/pandas-dev/pandas/pull/16845?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy90aW1lZGVsdGFzLnB5) | `90.58% <0%> (ø)` | :arrow_up: |
| [pandas/core/indexes/category.py](https://codecov.io/gh/pandas-dev/pandas/pull/16845?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy9jYXRlZ29yeS5weQ==) | `98.49% <0%> (ø)` | :arrow_up: |
| [pandas/core/indexes/multi.py](https://codecov.io/gh/pandas-dev/pandas/pull/16845?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy9tdWx0aS5weQ==) | `96.66% <0%> (+0.01%)` | :arrow_up: |
| [pandas/tseries/frequencies.py](https://codecov.io/gh/pandas-dev/pandas/pull/16845?src=pr&el=tree#diff-cGFuZGFzL3RzZXJpZXMvZnJlcXVlbmNpZXMucHk=) | `96.08% <0%> (+0.05%)` | :arrow_up: |
| [pandas/core/indexes/datetimes.py](https://codecov.io/gh/pandas-dev/pandas/pull/16845?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy9kYXRldGltZXMucHk=) | `95.33% <0%> (+0.09%)` | :arrow_up: |
| [pandas/compat/numpy/function.py](https://codecov.io/gh/pandas-dev/pandas/pull/16845?src=pr&el=tree#diff-cGFuZGFzL2NvbXBhdC9udW1weS9mdW5jdGlvbi5weQ==) | `93.12% <0%> (+0.17%)` | :arrow_up: |
| ... and [1 more](https://codecov.io/gh/pandas-dev/pandas/pull/16845?src=pr&el=tree-more) | |

------

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

Somehow the test for string fail, even though it worked on my computer (windows).I've set it to xfail now (the line ``pytest.mark.xfail((str, np.dtype('<U')), ),``), though I'm not sure it's the correct way to go about it.

thanks @topper-123 

ok next steps,  I think the ones you marked the xfails should work.

Note we will have to run perf tests to assure we are not changing too much.
Good work @topper-123 

FYI the asv benchmarks are being automatically run on our machine, and posted to https://tomaugspurger.github.io/asv-collection/pandas/, Just need to find a permanent home for them now.