ERR: add stacklevel to to_dict() UserWarning (#16927)
 - [x] closes #16927 
 - [ ] tests added / passed
 - [x] passes ``git diff upstream/master --name-only -- '*.py' | flake8 --diff`` (On Windows, ``git diff upstream/master -u -- "*.py" | flake8 --diff`` might work as an alternative.)
 - [x] The warning now correctly points to the calling site.

I would like some guidance on how to implement testing for this quick fix. I was thinking on using pytest's [warning assertion](https://docs.pytest.org/en/latest/warnings.html#warns), but couldn't figure out how to make it elegantly.

Cheers! :beers:

Hello @alanbato! Thanks for updating the PR.

 - In the file [`pandas/core/frame.py`](https://github.com/pandas-dev/pandas/blob/96cc9baabbcbcfd3efae09f3a01425c9f0856bde/pandas/core/frame.py), following are the PEP8 issues :

> [Line 2046:9](https://github.com/pandas-dev/pandas/blob/96cc9baabbcbcfd3efae09f3a01425c9f0856bde/pandas/core/frame.py#L2046): [E722](https://duckduckgo.com/?q=pep8%20E722) do not use bare except'
> [Line 2480:13](https://github.com/pandas-dev/pandas/blob/96cc9baabbcbcfd3efae09f3a01425c9f0856bde/pandas/core/frame.py#L2480): [E722](https://duckduckgo.com/?q=pep8%20E722) do not use bare except'
> [Line 5222:21](https://github.com/pandas-dev/pandas/blob/96cc9baabbcbcfd3efae09f3a01425c9f0856bde/pandas/core/frame.py#L5222): [E722](https://duckduckgo.com/?q=pep8%20E722) do not use bare except'
> [Line 5718:9](https://github.com/pandas-dev/pandas/blob/96cc9baabbcbcfd3efae09f3a01425c9f0856bde/pandas/core/frame.py#L5718): [E722](https://duckduckgo.com/?q=pep8%20E722) do not use bare except'





##### Comment last updated on July 15, 2017 at 14:59 Hours UTC @alanbato : Thanks for this PR!  FYI, ignore the PEP8 bot.  We are experimenting with this. I did a quick GitHub search for this warning, and I don't see it anywhere in our tests.  Could you add a test that triggers this warning? > I would like some guidance on how to implement testing for this quick fix. I was thinking on using pytest's warning assertion, but couldn't figure out how to make it elegantly.

Just read this after I submitted my question :smile:  Don't try to use `pytest's` warning assertion, as we have our custom one called `assert_produces_warning` from `pandas.util.testing`. Sure! should I add it to the `pandas/tests/frame/test_convert_to.py` file below the error assertions? Or should I create a new file? Yes, absolutely!  That's definitely the right place to put it. # [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/16936?src=pr&el=h1) Report
> Merging [#16936](https://codecov.io/gh/pandas-dev/pandas/pull/16936?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/ad24759871ea43131711cfce1e5fc69c06d82956?src=pr&el=desc) will **decrease** coverage by `0.01%`.
> The diff coverage is `n/a`.

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

```diff
@@            Coverage Diff             @@
##           master   #16936      +/-   ##
==========================================
- Coverage   90.99%   90.98%   -0.02%     
==========================================
  Files         161      161              
  Lines       49306    49306              
==========================================
- Hits        44868    44859       -9     
- Misses       4438     4447       +9
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `88.75% <ø> (ø)` | :arrow_up: |
| #single | `40.19% <ø> (-0.07%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/16936?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/frame.py](https://codecov.io/gh/pandas-dev/pandas/pull/16936?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZnJhbWUucHk=) | `97.71% <ø> (-0.1%)` | :arrow_down: |
| [pandas/io/gbq.py](https://codecov.io/gh/pandas-dev/pandas/pull/16936?src=pr&el=tree#diff-cGFuZGFzL2lvL2dicS5weQ==) | `25% <0%> (-58.34%)` | :arrow_down: |

------

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

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

```diff
@@            Coverage Diff             @@
##           master   #16936      +/-   ##
==========================================
- Coverage   90.99%   90.98%   -0.02%     
==========================================
  Files         161      161              
  Lines       49306    49288      -18     
==========================================
- Hits        44868    44846      -22     
- Misses       4438     4442       +4
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `88.75% <ø> (ø)` | :arrow_up: |
| #single | `40.2% <ø> (-0.06%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/16936?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/frame.py](https://codecov.io/gh/pandas-dev/pandas/pull/16936?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZnJhbWUucHk=) | `97.76% <ø> (-0.05%)` | :arrow_down: |
| [pandas/io/gbq.py](https://codecov.io/gh/pandas-dev/pandas/pull/16936?src=pr&el=tree#diff-cGFuZGFzL2lvL2dicS5weQ==) | `25% <0%> (-58.34%)` | :arrow_down: |
| [pandas/compat/\_\_init\_\_.py](https://codecov.io/gh/pandas-dev/pandas/pull/16936?src=pr&el=tree#diff-cGFuZGFzL2NvbXBhdC9fX2luaXRfXy5weQ==) | `60.67% <0%> (-1.55%)` | :arrow_down: |
| [pandas/core/panel.py](https://codecov.io/gh/pandas-dev/pandas/pull/16936?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvcGFuZWwucHk=) | `96.94% <0%> (ø)` | :arrow_up: |

------

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