ENH: add np.nan funcs to _cython_table
closes #19629 
closes #21134
- [x] tests added / passed
- [x] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`
- [x] whatsnew entry

This started as a copy of #19670 by @AaronCritchley, but has solved two bugs that the tests surfaced along the way.

Bug 1:
there is currently a bug in ``df.aggregate``, where the method incorrectly defers to ``df.apply`` in a corner case. This only shows up in the result when using numpy < 1.13 and passing np.nan* functions to ``df.aggregate``. This is the reason for the change in ``base.py`` line 571. (see #8383 for further details on the bug in numpy<1.13 and how it affects pandas.)

Bug 2:
Passing builtins to ``df.aggregate`` is ok when ``axis=0``, but gives wrong result,when ``axis=1`` (#21134). The reason for this difference is that ``df.aggregate`` defers to ``df._aggregate`` when ``axis=0,`` but defers to ``df.apply``, when ``axis=1``, and these give different result when passed funcions  and the series/frame contains Nan values. This can be solved by transposing df and defering the transposed frame to its ``_aggragate`` method when ``axis=1``.

The added tests have been heavily parametrized (this helped unearth the bugs above). Thet have been placed in ``series/test_apply.py`` and ``frame/test_apply``, as a lot of other tests for ser/df.aggregate were already there. 
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/21123?src=pr&el=h1) Report
> Merging [#21123](https://codecov.io/gh/pandas-dev/pandas/pull/21123?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/f6abb6148c8dc14e6279f31f2e620ecf52822107?src=pr&el=desc) will **increase** coverage by `<.01%`.
> The diff coverage is `100%`.

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

```diff
@@            Coverage Diff             @@
##           master   #21123      +/-   ##
==========================================
+ Coverage   91.84%   91.84%   +<.01%     
==========================================
  Files         153      153              
  Lines       49505    49512       +7     
==========================================
+ Hits        45466    45473       +7     
  Misses       4039     4039
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.24% <100%> (ø)` | :arrow_up: |
| #single | `41.88% <21.87%> (ø)` | :arrow_up: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/21123?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/frame.py](https://codecov.io/gh/pandas-dev/pandas/pull/21123/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZnJhbWUucHk=) | `97.22% <100%> (-0.01%)` | :arrow_down: |
| [pandas/core/groupby/groupby.py](https://codecov.io/gh/pandas-dev/pandas/pull/21123/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZ3JvdXBieS9ncm91cGJ5LnB5) | `92.66% <100%> (ø)` | :arrow_up: |
| [pandas/core/base.py](https://codecov.io/gh/pandas-dev/pandas/pull/21123/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYmFzZS5weQ==) | `96.87% <100%> (+0.04%)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/21123?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/21123?src=pr&el=footer). Last update [f6abb61...580edcf](https://codecov.io/gh/pandas-dev/pandas/pull/21123?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
 Hello @topper-123! Thanks for updating the PR.













Cheers ! There are no PEP8 issues in this Pull Request. :beers: 

##### Comment last updated on May 26, 2018 at 07:47 Hours UTC The travis failures say "Different tests were collected between gw1 and gw0. The difference is:..."

I don't *think* this has anything to do with my PR, anyone knows? I have not seen that before - I'd say let's just take a look after your next push and see if it repeats All the failures are of the type 

```
Different tests were collected between gw0 and gw1. The difference is:
--- gw0
+++ gw1
```

Everything passes locally. Don't think this has anything to do with my PR. I can try push again, but this has been every time so far, so don't think that will help... The failure above has been solved, it was a mistake concerning python3.5 dicts in xdist in ``conftest.py``: python3.5 randomizes dict retrieval, and of course  xdist doesnt like randomizing work distribution. I`ve made the params parameter in ``cython_table`` in ``conftest.py`` deterministic, so it doesnt happen again. I`ve rewritten the tests to now have expected results also. as @WillAyd indicates, can you split this up into a cython table PR and on top of that the agg fixes? 

first should be straightforward and we can get it quickly. pls put tests, changes and whatsnew for that one (in this PR is fine), and issue another PR for other changes. Closing in favor of #22109.