Prevent Unlimited Agg Recursion with Duplicate Col Names
State: closed

- [X] closes #21063
- [X] tests added / passed
- [X] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`
- [x] whatsnew entry

The `_gotitem` implementation for `DataFrame` seems a little strange so there may be a more comprehensive approach, but this should prevent the issue for the time being

Didn't add whatsnew yet since none existed for 0.23.1. Happy to add if we are OK with this fix

Labels:
name: Bug
name: Indexing
description: Related to indexing on series/frames, not to indexes themselves
name: Reshaping
description: Concat, Merge/Join, Stack/Unstack, Explode

Comments:
I have https://github.com/pandas-dev/pandas/pull/21001 for the whatsnew. Will merge after tagging 0.23.0
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/21066?src=pr&el=h1) Report
> Merging [#21066](https://codecov.io/gh/pandas-dev/pandas/pull/21066?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/501f0418c00064f5041ef156ed5a2289a9064da3?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/21066/graphs/tree.svg?height=150&width=650&token=eZ4WkYLtcO&src=pr)](https://codecov.io/gh/pandas-dev/pandas/pull/21066?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master   #21066      +/-   ##
==========================================
- Coverage   91.83%   91.83%   -0.01%     
==========================================
  Files         153      153              
  Lines       49495    49497       +2     
==========================================
  Hits        45454    45454              
- Misses       4041     4043       +2
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.22% <100%> (-0.01%)` | :arrow_down: |
| #single | `41.88% <16.66%> (-0.01%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/21066?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/base.py](https://codecov.io/gh/pandas-dev/pandas/pull/21066/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYmFzZS5weQ==) | `96.83% <100%> (ø)` | :arrow_up: |
| [pandas/core/frame.py](https://codecov.io/gh/pandas-dev/pandas/pull/21066/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZnJhbWUucHk=) | `97.23% <100%> (ø)` | :arrow_up: |
| [pandas/util/testing.py](https://codecov.io/gh/pandas-dev/pandas/pull/21066/diff?src=pr&el=tree#diff-cGFuZGFzL3V0aWwvdGVzdGluZy5weQ==) | `84.38% <0%> (-0.21%)` | :arrow_down: |

------

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

FYI, the whasnew is available now.
lgtm. ping on green. note am happy to simplification / refactoring of code here, though there are a lot of usecases so this is tricky.
Failed on AppVeyor but does not appear to be related (looks like a UserWarning wasn't being thrown for an io test with the PythonParser?)
Looks good. I'll keep an eye on the appveyor test in case it's relevant.