ENH-19629: Adding numpy nansun/nanmean, etc etc to _cython_table
State: closed

- [x] closes #19629 
- [x] tests added / passed
- [x] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`
- [x] whatsnew entry

As per the issue, here's proof of solution:
```python
Python 3.6.4 |Anaconda, Inc.| (default, Jan 16 2018, 12:04:33) 
[GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pandas as pd
>>> import numpy as np
>>> pd.Series([1,2,3,4]).agg(np.sum)
10
>>> pd.Series([1,2,3,4]).agg(np.nansum)
10
```

Where should I add tests for these changes? I wasn't sure on the best fit and how to most effectively test. Also, is a whatsnew entry needed here? If yes, any guidance on what it should be?

Labels:
name: Missing-data
description: np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate
name: Numeric Operations
description: Arithmetic, Comparison, and Logical operations

Comments:
Best is probably `pandas/tests/test_nanops.py`.

A whatsnew entry under bug fixes would be good, under the "Numeric" bug fixes section, saying that

    :meth:`~DataFrame.agg` now correctly handles numpy NaN-aware methods like :meth:`numpy.nansum` (:issue:`19629`)
Hello @AaronCritchley! Thanks for updating the PR.





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

##### Comment last updated on April 25, 2018 at 11:23 Hours UTC
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/19670?src=pr&el=h1) Report
> Merging [#19670](https://codecov.io/gh/pandas-dev/pandas/pull/19670?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/7ec74e5f7b1f9a379b318153da88092cccb855cc?src=pr&el=desc) will **increase** coverage by `0.06%`.
> The diff coverage is `100%`.

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

```diff
@@            Coverage Diff             @@
##           master   #19670      +/-   ##
==========================================
+ Coverage   91.77%   91.84%   +0.06%     
==========================================
  Files         153      153              
  Lines       49257    49300      +43     
==========================================
+ Hits        45207    45279      +72     
+ Misses       4050     4021      -29
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.23% <100%> (+0.06%)` | :arrow_up: |
| #single | `41.9% <100%> (+0.02%)` | :arrow_up: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/19670?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/base.py](https://codecov.io/gh/pandas-dev/pandas/pull/19670/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYmFzZS5weQ==) | `96.83% <100%> (+0.03%)` | :arrow_up: |
| [pandas/util/testing.py](https://codecov.io/gh/pandas-dev/pandas/pull/19670/diff?src=pr&el=tree#diff-cGFuZGFzL3V0aWwvdGVzdGluZy5weQ==) | `84.59% <0%> (-0.21%)` | :arrow_down: |
| [pandas/core/internals.py](https://codecov.io/gh/pandas-dev/pandas/pull/19670/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW50ZXJuYWxzLnB5) | `95.53% <0%> (-0.05%)` | :arrow_down: |
| [pandas/core/indexes/datetimes.py](https://codecov.io/gh/pandas-dev/pandas/pull/19670/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy9kYXRldGltZXMucHk=) | `95.73% <0%> (-0.04%)` | :arrow_down: |
| [pandas/core/accessor.py](https://codecov.io/gh/pandas-dev/pandas/pull/19670/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYWNjZXNzb3IucHk=) | `98.7% <0%> (-0.02%)` | :arrow_down: |
| [pandas/core/dtypes/concat.py](https://codecov.io/gh/pandas-dev/pandas/pull/19670/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZHR5cGVzL2NvbmNhdC5weQ==) | `99.16% <0%> (-0.02%)` | :arrow_down: |
| [pandas/core/strings.py](https://codecov.io/gh/pandas-dev/pandas/pull/19670/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvc3RyaW5ncy5weQ==) | `98.32% <0%> (-0.02%)` | :arrow_down: |
| [pandas/core/indexes/multi.py](https://codecov.io/gh/pandas-dev/pandas/pull/19670/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy9tdWx0aS5weQ==) | `95.06% <0%> (-0.02%)` | :arrow_down: |
| [pandas/core/window.py](https://codecov.io/gh/pandas-dev/pandas/pull/19670/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvd2luZG93LnB5) | `96.29% <0%> (-0.01%)` | :arrow_down: |
| [pandas/core/frame.py](https://codecov.io/gh/pandas-dev/pandas/pull/19670/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZnJhbWUucHk=) | `97.16% <0%> (-0.01%)` | :arrow_down: |
| ... and [13 more](https://codecov.io/gh/pandas-dev/pandas/pull/19670/diff?src=pr&el=tree-more) | |

------

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

Hey @TomAugspurger - thanks so much for your help. Are the tests I've put in OK or would you rather me be more exhaustive?

I considered adding in some tests with `np.nan` values but in some functions, like `np.nancumsum`, that changes the output and I thought it would be messy adding in `np.nan` tests on some, but not all functions.
``np.nanprod`` was added in numpy 1.10, while pandas supports numpy 1.9. 

So in the parametrization you need to add a ``skipif`` part wrt. ``np.nanprod``. See [here](https://docs.pytest.org/en/latest/skipping.html#skip-xfail-with-parametrize) for an example.
@topper-123 thank you so much - I ended up changing the implementation rather than just xfailing the test, as the failure in the build was being hit in a non-test scenario, if you have better suggestions I'm happy to take them on!
can you rebase
@AaronCritchley are these failures related to your changes? https://travis-ci.org/pandas-dev/pandas/jobs/351535340#L2351
Hey @TomAugspurger, yep, I believe they are, I need to figure out the issue as everything passes locally. Open to suggestions if it's super obvious to you but happy to dive further if not. Seems like different behaviour in np.nanmax in that particular ci configuration.

Also trying to get in the suggestions made by Jeff around using fixtures for the series / df once I've figured it out the above :smile: 
Refactored to make use of fixtures and rebased, still need to dig into the 3.5 build failure and figure out what's happening, help appreciated 😄 
looks fine. ping on green.
can you rebase
can you rebase
Hey @jreback, I've rebased, the CI pipeline is failing a single test on a single env - I'm looking into it but was having a hard time recreating the failed test. If it's anything obvious help would be much appreciated, I'll continue to dig and try to figure it out.

EDIT: I can recreate the test now, which is good, but still haven't figured out the cause, will update if I find anything.
Going to close this in case any other contributors are able to pick it up, if it doesn't get picked up I'll try to fix again at a later date 😄