BUG: Fix regression in DataFrame.apply causing RecursionError
State: closed

- [X] closes #25196
- [X] tests added / passed
- [X] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`
- [x] whatsnew entry

With this change the snippets reported in the issue work as expected:

```
>>> import numpy as np
>>> import pandas as pd
>>> df = pd.DataFrame(np.zeros((100, 15)))
>>> df.T.apply(dict)
0     {0: 0.0, 1: 0.0, 2: 0.0, 3: 0.0, 4: 0.0, 5: 0....
1     {0: 0.0, 1: 0.0, 2: 0.0, 3: 0.0, 4: 0.0, 5: 0....
2     {0: 0.0, 1: 0.0, 2: 0.0, 3: 0.0, 4: 0.0, 5: 0....
3     {0: 0.0, 1: 0.0, 2: 0.0, 3: 0.0, 4: 0.0, 5: 0....
4     {0: 0.0, 1: 0.0, 2: 0.0, 3: 0.0, 4: 0.0, 5: 0....
5     {0: 0.0, 1: 0.0, 2: 0.0, 3: 0.0, 4: 0.0, 5: 0....
6     {0: 0.0, 1: 0.0, 2: 0.0, 3: 0.0, 4: 0.0, 5: 0....
7     {0: 0.0, 1: 0.0, 2: 0.0, 3: 0.0, 4: 0.0, 5: 0....
8     {0: 0.0, 1: 0.0, 2: 0.0, 3: 0.0, 4: 0.0, 5: 0....
9     {0: 0.0, 1: 0.0, 2: 0.0, 3: 0.0, 4: 0.0, 5: 0....
10    {0: 0.0, 1: 0.0, 2: 0.0, 3: 0.0, 4: 0.0, 5: 0....
11    {0: 0.0, 1: 0.0, 2: 0.0, 3: 0.0, 4: 0.0, 5: 0....
...
```

Labels:
name: Regression
description: Functionality that used to work in a prior pandas version
name: DataFrame
description: DataFrame data structure

Comments:
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/25230?src=pr&el=h1) Report
> Merging [#25230](https://codecov.io/gh/pandas-dev/pandas/pull/25230?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/1d1b14c7ea7c3e497b66453cacbb8230b26cb6a6?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/25230/graphs/tree.svg?width=650&token=eZ4WkYLtcO&height=150&src=pr)](https://codecov.io/gh/pandas-dev/pandas/pull/25230?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master   #25230      +/-   ##
==========================================
- Coverage   92.15%   92.15%   -0.01%     
==========================================
  Files         166      166              
  Lines       52294    52292       -2     
==========================================
- Hits        48194    48192       -2     
  Misses       4100     4100
```

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

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/25230?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/dtypes/inference.py](https://codecov.io/gh/pandas-dev/pandas/pull/25230/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZHR5cGVzL2luZmVyZW5jZS5weQ==) | `98.41% <100%> (-0.05%)` | :arrow_down: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/25230?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/25230?src=pr&el=footer). Last update [1d1b14c...ec7e1ac](https://codecov.io/gh/pandas-dev/pandas/pull/25230?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/25230?src=pr&el=h1) Report
> Merging [#25230](https://codecov.io/gh/pandas-dev/pandas/pull/25230?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/1d1b14c7ea7c3e497b66453cacbb8230b26cb6a6?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/25230/graphs/tree.svg?width=650&token=eZ4WkYLtcO&height=150&src=pr)](https://codecov.io/gh/pandas-dev/pandas/pull/25230?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master   #25230      +/-   ##
==========================================
- Coverage   92.15%   92.15%   -0.01%     
==========================================
  Files         166      166              
  Lines       52294    52292       -2     
==========================================
- Hits        48194    48191       -3     
- Misses       4100     4101       +1
```

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

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/25230?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/dtypes/inference.py](https://codecov.io/gh/pandas-dev/pandas/pull/25230/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZHR5cGVzL2luZmVyZW5jZS5weQ==) | `98.41% <100%> (-0.05%)` | :arrow_down: |
| [pandas/util/testing.py](https://codecov.io/gh/pandas-dev/pandas/pull/25230/diff?src=pr&el=tree#diff-cGFuZGFzL3V0aWwvdGVzdGluZy5weQ==) | `87.89% <0%> (-0.1%)` | :arrow_down: |

------

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

@jschendel can you give it another look? I've included your feedback, it should be good to go 🙂 
@WillAyd @jschendel how does it look right now? I should've included you're very last feedback
@jreback 
thans @gioiab