BUG: groupby's first/last functions maintain Series rather than convert to numpy array (#15884)
State: closed

 - [x] closes #15884 
 - [x] tests added / passed
 - [x] passes ``git diff upstream/master --name-only -- '*.py' | flake8 --diff``
 - [x] whatsnew entry


Labels:

Comments:
@chrisaycock not what I was looking for. The only reason that compat routine is called is because the block aggregator raises. So this will not be performant. I don't think these compat routines are actually called at all (or should be). All of the handling is now done via the cython routines (I *think).
So these compat routines are *only* called if ``numeric_only=False`` is passed. It tries the cython path first. So for datetimes it *should* be working (but is raising because its being called incorrectly).
@jreback Those compat functions were definitely being called for the test case, which is how I found them. If they aren't supposed to be called, then I'll have to take another crack at that issue.
@chrisaycock not what I mean.

put a breakpoint in ``_cython_agg_blocks``. It is hit *first* (pun intended). This raises (incorrectly), then the compat routines are called.
@jreback Ok, I see what you mean. The `.values` is definitely a `DatetimeIndex` instead of a multi-dimensional array.
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/15885?src=pr&el=h1) Report
> Merging [#15885](https://codecov.io/gh/pandas-dev/pandas/pull/15885?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/da0523a346abd9575ab05746e242ec67c1c442d4?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/15885/graphs/tree.svg?src=pr&width=650&token=eZ4WkYLtcO&height=150)](https://codecov.io/gh/pandas-dev/pandas/pull/15885?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master   #15885      +/-   ##
==========================================
- Coverage   90.97%   90.96%   -0.01%     
==========================================
  Files         145      145              
  Lines       49483    49481       -2     
==========================================
- Hits        45015    45012       -3     
- Misses       4468     4469       +1
```

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

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/15885?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/groupby.py](https://codecov.io/gh/pandas-dev/pandas/pull/15885?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZ3JvdXBieS5weQ==) | `95.02% <100%> (-0.01%)` | :arrow_down: |
| [pandas/core/common.py](https://codecov.io/gh/pandas-dev/pandas/pull/15885?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvY29tbW9uLnB5) | `90.68% <0%> (-0.35%)` | :arrow_down: |

------

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