API: fix corner case of lib.infer_dtype
State: closed

- [x] closes #23421
- [x] tests added / passed
- [x] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`
- [x] whatsnew entry

Working towards #23167 needs fixing of the type inference for some corner cases (especially not inferring an object column full of NaNs to be `'floating'`).


Labels:
name: Dtype Conversions
description: Unexpected or buggy dtype conversions
name: Internals
description: Related to non-user accessible pandas implementation

Comments:
Hello @h-vetinari! Thanks for submitting the PR.

 - There are no PEP8 issues in the file [`pandas/tests/dtypes/test_inference.py`](https://github.com/h-vetinari/pandas/blob/8e1e97e7d38005d7e209227525afe6597f7c7356/pandas/tests/dtypes/test_inference.py) !


# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/23422?src=pr&el=h1) Report
> Merging [#23422](https://codecov.io/gh/pandas-dev/pandas/pull/23422?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/d78bd7a65f87022bae5021d36c8656c0ea5a7b76?src=pr&el=desc) will **not change** coverage.
> The diff coverage is `n/a`.

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

```diff
@@           Coverage Diff           @@
##           master   #23422   +/-   ##
=======================================
  Coverage   92.23%   92.23%           
=======================================
  Files         161      161           
  Lines       51197    51197           
=======================================
  Hits        47220    47220           
  Misses       3977     3977
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.61% <ø> (ø)` | :arrow_up: |
| #single | `42.27% <ø> (ø)` | :arrow_up: |


------

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

Annoyingly, `io.sql.SQLTable.create_table` needs to have the `dtype` returned even for empty columns, otherwise the test for empty tables fails. I had been able to fix the pytables failures that appeared in the CI, but I'm now reverting that (breaking) change.

I still think it's a good idea, but fixing that - depending on the use case - would probably need another keyword that determines whether to prioritize `'empty'` over the dtype or vice versa.

In any case, what remains of this PR is fixing a corner case that is more clearly wrong (returning `'floating'` for an all-NA object column if `skipna=True`).
@gfyoung 
Could you please restart the failed travis job. It was a hypothesis timeout, nothing else.
@jreback 
There are two aspects to #23421:
1. whether `lib.infer_dtype(pd.Series([]))` returns `'floating'` vs. `'empty'` 
1. whether `lib.infer_dtype(pd.Series([np.nan, np.nan], dtype=object), skipna=True)` returns `'floating'` vs. `'empty'` 

I've reverted the fix for 1. (after the SQL errors I mentioned above), but kept 2. This is also not about the issue you linked #17261, but about an oversight of #17066. All-NA `object` column + `skipna=True` should clearly not return `'floating'` (and this is causing errors in #23167).
@jreback 
All green.
can you rebase
thanks