Disable M8 in nanops
State: closed

Closes https://github.com/pandas-dev/pandas/issues/24752

xref https://github.com/pandas-dev/pandas/commit/fe696e453b9236b226a0656028be43b4706ce1a1#diff-12444145caa7d0c14da51377a05e46d6

Labels:
name: Datetime
description: Datetime data dtype
name: Regression
description: Functionality that used to work in a prior pandas version
name: Numeric Operations
description: Arithmetic, Comparison, and Logical operations

Comments:
cc @jbrockmendel, this probably breaks your other PR badly. But I'm not sure what's best to do here...


The whole `DataFrame._reduce` implementation seems ripe for a refactor. In principal, we should know *ahead* of time if the op in question is valid for the dtype, no need for all the try / excepts.

And we really shouldn't be applying the op it to `df.values`. It should be done block or column-wise.
For historical note: this reverts partly https://github.com/pandas-dev/pandas/pull/24293 (the part of allowing nanmean on M8 data)
@TomAugspurger there is some datetime64 check inside `nanmean` that was added in that PR, which could now in principle be removed (but minor detail, shouldn't matter)
Yes, I've left it for now, to make the re-revert easier when we do decide to implement this. But I can do either way.
Had to rework `disallow` slightly to handle extension dtypes.
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/24907?src=pr&el=h1) Report
> Merging [#24907](https://codecov.io/gh/pandas-dev/pandas/pull/24907?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/e2c0b120eb19ecc93a70f9a9c3cb51417cb55d1f?src=pr&el=desc) will **decrease** coverage by `49.49%`.
> The diff coverage is `100%`.

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

```diff
@@            Coverage Diff             @@
##           master   #24907      +/-   ##
==========================================
- Coverage   92.38%   42.89%   -49.5%     
==========================================
  Files         166      166              
  Lines       52411    52412       +1     
==========================================
- Hits        48422    22480   -25942     
- Misses       3989    29932   +25943
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `?` | |
| #single | `42.89% <100%> (-0.01%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/24907?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/nanops.py](https://codecov.io/gh/pandas-dev/pandas/pull/24907/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvbmFub3BzLnB5) | `31.39% <100%> (-62.97%)` | :arrow_down: |
| [pandas/io/formats/latex.py](https://codecov.io/gh/pandas-dev/pandas/pull/24907/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2Zvcm1hdHMvbGF0ZXgucHk=) | `0% <0%> (-100%)` | :arrow_down: |
| [pandas/core/categorical.py](https://codecov.io/gh/pandas-dev/pandas/pull/24907/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvY2F0ZWdvcmljYWwucHk=) | `0% <0%> (-100%)` | :arrow_down: |
| [pandas/io/sas/sas\_constants.py](https://codecov.io/gh/pandas-dev/pandas/pull/24907/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL3Nhcy9zYXNfY29uc3RhbnRzLnB5) | `0% <0%> (-100%)` | :arrow_down: |
| [pandas/tseries/plotting.py](https://codecov.io/gh/pandas-dev/pandas/pull/24907/diff?src=pr&el=tree#diff-cGFuZGFzL3RzZXJpZXMvcGxvdHRpbmcucHk=) | `0% <0%> (-100%)` | :arrow_down: |
| [pandas/tseries/converter.py](https://codecov.io/gh/pandas-dev/pandas/pull/24907/diff?src=pr&el=tree#diff-cGFuZGFzL3RzZXJpZXMvY29udmVydGVyLnB5) | `0% <0%> (-100%)` | :arrow_down: |
| [pandas/io/formats/html.py](https://codecov.io/gh/pandas-dev/pandas/pull/24907/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2Zvcm1hdHMvaHRtbC5weQ==) | `0% <0%> (-99.35%)` | :arrow_down: |
| [pandas/core/groupby/categorical.py](https://codecov.io/gh/pandas-dev/pandas/pull/24907/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZ3JvdXBieS9jYXRlZ29yaWNhbC5weQ==) | `0% <0%> (-95.46%)` | :arrow_down: |
| [pandas/io/sas/sas7bdat.py](https://codecov.io/gh/pandas-dev/pandas/pull/24907/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL3Nhcy9zYXM3YmRhdC5weQ==) | `0% <0%> (-91.17%)` | :arrow_down: |
| [pandas/io/sas/sas\_xport.py](https://codecov.io/gh/pandas-dev/pandas/pull/24907/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL3Nhcy9zYXNfeHBvcnQucHk=) | `0% <0%> (-90.15%)` | :arrow_down: |
| ... and [124 more](https://codecov.io/gh/pandas-dev/pandas/pull/24907/diff?src=pr&el=tree-more) | |

------

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

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

```diff
@@            Coverage Diff             @@
##           master   #24907      +/-   ##
==========================================
- Coverage   92.38%   92.38%   -0.01%     
==========================================
  Files         166      166              
  Lines       52411    52413       +2     
==========================================
- Hits        48422    48421       -1     
- Misses       3989     3992       +3
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.8% <100%> (-0.01%)` | :arrow_down: |
| #single | `42.89% <100%> (ø)` | :arrow_up: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/24907?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/nanops.py](https://codecov.io/gh/pandas-dev/pandas/pull/24907/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvbmFub3BzLnB5) | `93.84% <100%> (-0.53%)` | :arrow_down: |

------

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

lgtm. merge when ready
If this helps get 0.24.0 out the door, I say go for it.
> The whole DataFrame._reduce implementation seems ripe for a refactor [...] this should be done block of column-wise

+1
>  this probably breaks your other PR badly

I'll double-check, probably.  Regardless, that PR is stalled until someone (hint: Tom or Joris?) helps resolve a communication problem.