implement libmissing; untangles _libs dependencies
State: closed

In the status quo, `algos`, `hashtable`, `parsers`, and `period` depend on `lib`.  On top of that `groupby`, `join`, and `index` depend on `algos` and `intervaltree` depends on `hashtable`.  (In fairness, some of these dependency relationships are python imports, not cimports.)

`lib` depends on `tslib` which depends on essentially all of `tslibs`.  So we've got a whole bunch of dependencies (many of which aren't declared in setup.py).

But the `lib` functions needed by `algos`, `hashtable`, and `period` are basically all a small handful of null-checking `checnull`, `isnaobj`, `isnaobj2d` which depend only on `util` and `NaT`.

So this PR takes those functions and puts them into `_libs.missing`, then updates the relevant imports.


Labels:
name: Missing-data
description: np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate
name: Clean

Comments:
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/18357?src=pr&el=h1) Report
> Merging [#18357](https://codecov.io/gh/pandas-dev/pandas/pull/18357?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/cfad581e9a6d35c7d05d2b1f34e4a19f7ee15cc6?src=pr&el=desc) will **decrease** coverage by `0.01%`.
> The diff coverage is `100%`.

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

```diff
@@            Coverage Diff             @@
##           master   #18357      +/-   ##
==========================================
- Coverage   91.38%   91.36%   -0.02%     
==========================================
  Files         164      164              
  Lines       49790    49791       +1     
==========================================
- Hits        45501    45493       -8     
- Misses       4289     4298       +9
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `89.17% <100%> (ø)` | :arrow_up: |
| #single | `39.5% <50%> (-0.06%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/18357?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/io/formats/format.py](https://codecov.io/gh/pandas-dev/pandas/pull/18357?src=pr&el=tree#diff-cGFuZGFzL2lvL2Zvcm1hdHMvZm9ybWF0LnB5) | `96.01% <100%> (ø)` | :arrow_up: |
| [pandas/core/dtypes/missing.py](https://codecov.io/gh/pandas-dev/pandas/pull/18357?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZHR5cGVzL21pc3NpbmcucHk=) | `90.62% <100%> (ø)` | :arrow_up: |
| [pandas/io/formats/excel.py](https://codecov.io/gh/pandas-dev/pandas/pull/18357?src=pr&el=tree#diff-cGFuZGFzL2lvL2Zvcm1hdHMvZXhjZWwucHk=) | `96.72% <100%> (+0.01%)` | :arrow_up: |
| [pandas/io/gbq.py](https://codecov.io/gh/pandas-dev/pandas/pull/18357?src=pr&el=tree#diff-cGFuZGFzL2lvL2dicS5weQ==) | `25% <0%> (-58.34%)` | :arrow_down: |
| [pandas/core/frame.py](https://codecov.io/gh/pandas-dev/pandas/pull/18357?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZnJhbWUucHk=) | `97.8% <0%> (-0.1%)` | :arrow_down: |

------

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

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

```diff
@@            Coverage Diff             @@
##           master   #18357      +/-   ##
==========================================
- Coverage   91.35%   91.33%   -0.02%     
==========================================
  Files         163      163              
  Lines       49714    49716       +2     
==========================================
- Hits        45415    45408       -7     
- Misses       4299     4308       +9
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `89.13% <100%> (ø)` | :arrow_up: |
| #single | `39.64% <58.82%> (-0.06%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/18357?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/dtypes/missing.py](https://codecov.io/gh/pandas-dev/pandas/pull/18357?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZHR5cGVzL21pc3NpbmcucHk=) | `90.74% <100%> (+0.11%)` | :arrow_up: |
| [pandas/io/formats/excel.py](https://codecov.io/gh/pandas-dev/pandas/pull/18357?src=pr&el=tree#diff-cGFuZGFzL2lvL2Zvcm1hdHMvZXhjZWwucHk=) | `96.71% <100%> (ø)` | :arrow_up: |
| [pandas/io/formats/format.py](https://codecov.io/gh/pandas-dev/pandas/pull/18357?src=pr&el=tree#diff-cGFuZGFzL2lvL2Zvcm1hdHMvZm9ybWF0LnB5) | `96.01% <100%> (ø)` | :arrow_up: |
| [pandas/io/gbq.py](https://codecov.io/gh/pandas-dev/pandas/pull/18357?src=pr&el=tree#diff-cGFuZGFzL2lvL2dicS5weQ==) | `25% <0%> (-58.34%)` | :arrow_down: |
| [pandas/core/frame.py](https://codecov.io/gh/pandas-dev/pandas/pull/18357?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZnJhbWUucHk=) | `97.8% <0%> (-0.1%)` | :arrow_down: |

------

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

rebase
pls rebase
> instead of importing iNaT, just use NPY_NAT to avoid perf issues.

> type as object

Just pushed with both these changes.  Also: 

- changed variable `v` --> `val` (there's a recent issue regarding linting too-short variable names that I _very_ much agree with)
- changed `for i from 0 <= i < n:`  --> `for i in range(n):` in a couple places

thanks!
not sure this started showing up on this PR, but pls add to the list
```
/Users/jreback/miniconda3/envs/pandas/lib/python3.6/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:15:2: warning: "Using deprecated NumPy API, disable it by "          "#defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-W#warnings]
#warning "Using deprecated NumPy API, disable it by " \
 ^
pandas/_libs/src/datetime/np_datetime.c:571:12: warning: expression result unused [-Wunused-value]
  meta.num - 1;
  ~~~~~~~~ ^ ~
pandas/_libs/src/datetime/np_datetime.c:1004:15: warning: unused variable 'perday' [-Wunused-variable]
    npy_int64 perday;
              ^
3 warnings generated.
```
> not sure this started showing up on this PR, but pls add to the list

Looks like these are in the new timedelta_struct functions, likely leftovers from copy/paste.  Easy to fix in-place, but I'd advocate not having them in src/ to begin with.  Put them directly in tslibs.np_datetime (or tslibs.np_timedelta).